Check if the sentence is pangram
August 21, 2022
array-and-hashmapProblem URL: Check if the sentence is pangram
We will count each character and add it to a hashmap. If the number of characters are equal to 26, we return true otherwise return false.
class Solution:
def checkIfPangram(self, sentence: str) -> bool:
count = collections.Counter(sentence)
return len(count) == 26
Time Complexity: O(n)
Space Complexity: O(n)