VOOZH about

URL: https://www.geeksforgeeks.org/dsa/pangram-checking/

⇱ Check if given String is Pangram or not - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check if given String is Pangram or not

Last Updated : 17 Feb, 2026

Given a string s, check if it is Pangram or not. 
A pangram is a sentence containing all letters of the English Alphabet.

Examples: 

Input: s = "The quick brown fox jumps over the lazy dog" 
Output: true
Explanation: The input string contains all characters from 'a' to 'z'.

Input: s = "The quick brown fox jumps over the dog"
Output: false
Explanation: The input string does not contain all characters from 'a' to 'z', as 'l', 'z', 'y' are missing

[Naive Approach] By Searching for each Character - O(26 * n) Time and O(1) Space

The idea is to iterate over all characters from 'a' to 'z' and for each character, check if it is present in the input string or not. If any character is not present in the input string, return false. Otherwise, return true. Also, we need to ignore the case while searching for a character('a' and 'A' are considered same).


Output
true

[Expected Approach] Using Visited Array - O(n) Time and O(26) Space

The idea is to create a visited array of size 26 to mark whether a character is present in the string or not. Now, iterate through all the characters of the string and mark them as visited. Lowercase and Uppercase are considered the same. So 'A' and 'a' are marked at index 0 and similarly 'Z' and 'z' are marked at index 25.

After iterating through all the characters, check whether all the characters are marked in visited array or not. If not then return false else return true.


Output
false
Comment
Article Tags: