We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defpangrams(s):# Convert string to lowercase once and create a set of charactersseen_letters=set(cforcins.lower()ifc.isalpha())# Check if the set contains all the letters of the alphabetis_pangram=len(seen_letters)==26return'pangram'ifis_pangramelse'notpangram'
unique = ""
for i in s.lower():
if i in string.ascii_lowercase and not i in unique:
unique += i
if len(unique) != 26:
return "not pangram"
else:
return "pangram"
solution in python:
Hey folks, I completed this problem by this solution, can anyone help me to analyse the time complexity for the below code,
import string
def pangrams(s):
TC: O(n) | SC: O(1)
string pangrams(string s) { int count = 0; int arr[26] = {0};
}