Check if the Sentence Is Pangram - Problem

A pangram is a fascinating type of sentence that contains every letter of the English alphabet at least once. The most famous example is "The quick brown fox jumps over the lazy dog."

Your task is to determine whether a given string is a pangram. You'll receive a sentence containing only lowercase English letters, and you need to return true if the sentence is a pangram, or false otherwise.

Think of it as checking if you have a complete collection - you need all 26 letters from 'a' to 'z' to appear at least once in your sentence!

Examples:

  • "thequickbrownfoxjumpsoverthelazydog" โ†’ true (contains all 26 letters)
  • "leetcode" โ†’ false (missing many letters)

Input & Output

example_1.py โ€” Complete Pangram
$ Input: sentence = "thequickbrownfoxjumpsoverthelazydog"
โ€บ Output: true
๐Ÿ’ก Note: This sentence contains every letter from 'a' to 'z' at least once, making it a perfect pangram.
example_2.py โ€” Incomplete Sentence
$ Input: sentence = "leetcode"
โ€บ Output: false
๐Ÿ’ก Note: This sentence only contains letters: e, l, t, c, o, d. It's missing 20 letters of the alphabet (a, b, f, g, h, i, j, k, m, n, p, q, r, s, u, v, w, x, y, z).
example_3.py โ€” Edge Case Single Letters
$ Input: sentence = "abcdefghijklmnopqrstuvwxyz"
โ€บ Output: true
๐Ÿ’ก Note: This string contains exactly one occurrence of each letter in alphabetical order, making it a minimal pangram.

Constraints

  • 1 โ‰ค sentence.length โ‰ค 1000
  • sentence consists of lowercase English letters only
  • No spaces, punctuation, or uppercase letters to worry about

Visualization

Tap to expand
๐ŸŽฏ Pangram Detection: The Stamp Collection๐Ÿ“ฌ Incoming Letters: "thequickbrownfox..."t h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g๐Ÿ“ฎ Collection Progress:Collected Stamps:abcde... (continue for all 26)Status: Found 26/26 unique letters โœ…Result: TRUE - Complete pangram! ๐ŸŽ‰โšก Key Insight: Stop as soon as collection is complete!๐Ÿ“Š Efficiency: O(n) time, O(1) space (max 26 letters)๐Ÿ’ก Algorithm Steps:1. Initialize empty stamp collection (hash set)2. For each character, add stamp to collection3. Return true when collection size = 26
Understanding the Visualization
1
Start Collection
Begin with empty collection, scan each character
2
Collect Letters
Add each new letter type to our collection
3
Check Completeness
Success when we have all 26 letter types
Key Takeaway
๐ŸŽฏ Key Insight: A pangram detection is essentially a set collection problem - we need to efficiently track which unique letters we've seen and check if we have all 26. The hash set approach with early termination gives us optimal performance!
Asked in
Google 12 Amazon 8 Apple 6 Microsoft 5
89.3K Views
Medium Frequency
~15 min Avg. Time
1.8K Likes
Ln 1, Col 1
Smart Actions
๐Ÿ’ก Explanation
AI Ready
๐Ÿ’ก Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen