-
Notifications
You must be signed in to change notification settings - Fork 1
/
CheckifSentencePangram.py
46 lines (35 loc) · 1.09 KB
/
CheckifSentencePangram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# A pangram is a sentence where every letter of the English alphabet appears at least once.
# Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.
#Using list to store unique characters
def checkIfPangram(sentence):
letters = []
if len(sentence) < 26:
return False
for char in sentence:
if char not in letters:
letters.append(char)
if len(letters) == 26:
return True
else:
return False
#Using set to store unique characters
def checkIfPangram2(sentence):
letters = set()
if len(sentence) < 26:
return False
for char in sentence:
letters.add(char)
if len(letters) == 26:
return True
else:
return False
#Test cases
sentence = "thequickbrownfoxjumpsoverthelazydog"
print(checkIfPangram(sentence))
print(checkIfPangram2(sentence))
sentence = "leetcode"
print(checkIfPangram(sentence))
print(checkIfPangram2(sentence))
sentence = "uwqohxamknblecdtzpisgvyfjr"
print(checkIfPangram(sentence))
print(checkIfPangram2(sentence))