Magicsheet logo

Check if the Sentence Is Pangram

Easy
100%
Updated 6/1/2025

Check if the Sentence Is Pangram

What is this problem about?

A pangram is a sentence that contains every letter of the English alphabet at least once. The "Check if the Sentence Is Pangram" coding problem asks you to determine if a given string sentence (consisting of lowercase English letters) meets this criteria.

Why is this asked in interviews?

This is a standard "Easy" question used by companies like Microsoft, Goldman Sachs, and Google to assess basic string processing and hash set usage. It's a test of efficiency—can you identify that once you've seen all 26 letters, you can stop early? It evaluations your familiarity with character encoding (ASCII) and set-based data structures.

Algorithmic pattern used

The pattern is Hash Table / Set counting. You iterate through the string and add each character to a Set. After the loop (or during the loop), you check if the size of the set is exactly 26. Alternatively, you can use a boolean array of size 26 or a bitmask (an integer where each bit represents a letter) to save space.

Example explanation

sentence="thequickbrownfoxjumpsoverthelazydog"sentence = "thequickbrownfoxjumpsoverthelazydog"

  1. Create a set.
  2. Add 't', 'h', 'e', 'q', 'u', 'i', 'c', 'k'...
  3. By the end of the sentence, every letter from 'a' to 'z' has been added.
  4. Set size is 26. Result: True. sentence="abcdefg"sentence = "abcdefg"
  5. Set size is 7. Result: False.

Common mistakes candidates make

A common mistake is not handling non-alphabetic characters (though the problem usually specifies lowercase English letters). Another is using a full hash table when a simple boolean array or bitmask would be more memory-efficient. Some candidates might also forget that the alphabet has exactly 26 letters.

Interview preparation tip

For problems involving a small, fixed set of keys (like the 26 letters of the alphabet), a bitmask is a highly efficient and "impressive" way to track seen elements. Practice using mask |= (1 << (char - 'a')) to set bits.

Similar Questions