Check if the Sentence Is Pangram
Problem Summary
- A sentence is Pangram if all 26 letters of the alphabet is used at least once
Main Concepts Used
(Mark the CS concepts or algorithms used.)
Time & Space Complexity
- Time:
→ Reason: Iterating through each letter in the sentence - Space:
→ Reason: Only storing upto 26 letters in the set
Code
class Solution:
def checkIfPangram(self, sentence: str) -> bool:
lettersSeen = set()
for character in sentence:
if character.isalpha():
lettersSeen.add(character.lower())
return len(lettersSeen) == 26