Pangram Checker - Problem

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

Given a string sentence, write a function to determine if it is a pangram. The check should be case-insensitive, meaning both uppercase and lowercase letters count.

Note: Only English alphabet letters (a-z) need to be considered. Numbers, spaces, and special characters can be ignored.

Input & Output

Example 1 — Classic Pangram
$ Input: sentence = "The quick brown fox jumps over the lazy dog"
Output: true
💡 Note: This famous sentence contains all 26 letters: t,h,e,q,u,i,c,k,b,r,o,w,n,f,x,j,m,p,s,v,l,a,z,y,d,g
Example 2 — Missing Letters
$ Input: sentence = "Hello world"
Output: false
💡 Note: Contains only 7 unique letters: h,e,l,o,w,r,d. Missing 19 letters including a,b,c,f,g,i,j,k,m,n,p,q,s,t,u,v,x,y,z
Example 3 — Mixed Case
$ Input: sentence = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Output: true
💡 Note: All 26 uppercase letters present. Case-insensitive check passes since all alphabet letters are covered

Constraints

  • 1 ≤ sentence.length ≤ 1000
  • sentence consists of lowercase and uppercase English letters, digits, and spaces

Visualization

Tap to expand
Pangram Checker Problem OverviewINPUT"The quick brown foxjumps over the lazy dog"Sentence to analyzeContains:• Letters (a-z, A-Z)• Spaces• Mixed caseGoal: Check if pangramALGORITHM1Create tracking structure2Scan each character3Mark alphabet letters4Count unique lettersOptimization:Stop early when26 letters foundRESULTtrueAll 26 letters foundLetters found:a, b, c, d, e, f, g, h, i, j, k,l, m, n, o, p, q, r, s, t, u,v, w, x, y, zComplexity:Time: O(n)Space: O(1)Key Insight:Track letters as you scan instead of searching for each letter individually.Early termination when all 26 letters found optimizes performance.TutorialsPoint - Pangram Checker | Early Termination with Boolean Array
Asked in
Google 15 Microsoft 12 Amazon 8
28.5K Views
Medium Frequency
~15 min Avg. Time
892 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