Problem Description
Given a string containing only lowercase English letters, determine if the sentence is a pangram, meaning it contains every letter of the English alphabet at least once.
Key Insights
- A pangram must include every letter from 'a' to 'z'.
- Use a data structure (like a hash set) to keep track of unique letters encountered.
- The check is successful if the size of the set is 26.
- Early exit is possible as soon as all 26 letters have been found.
Space and Time Complexity
Time Complexity: O(n), where n is the length of the sentence. Space Complexity: O(1), since the set will store at most 26 characters regardless of input size.
Solution
The solution involves iterating over the characters of the sentence and adding each character to a hash set. Since there are only 26 letters in the English alphabet, if the set size reaches 26 at any point, you can immediately return true. After processing all characters, if the set size is still less than 26, return false. An alternative approach is to use a fixed-size boolean array of size 26 to mark the presence of each letter.