array and hashmap August 21, 2022

Check if the sentence is pangram

Time O(n) Space O(n) Open original problem

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)