Given a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet.
Examples : The quick brown fox jumps over the lazy dog ” is a Pangram [Contains all the characters from ‘a’ to ‘z’]
“The quick brown fox jumps over the dog” is not a Pangram [Doesn’t contains all the characters from ‘a’ to ‘z’, as ‘l’, ‘z’, ‘y’ are missing]
We create a mark array of Boolean type. We iterate through all the characters of our string and whenever we see a character we mark it. Lowercase and Uppercase are considered the same. So ‘A’ and ‘a’ are marked in index 0 and similarly ‘Z’ and ‘z’ are marked in index 25.
After iterating through all the characters we check whether all the characters are marked or not. If not then return false as this is not a pangram else return true.
"The quick brown fox jumps over the lazy dog" is a pangram
Time Complexity: O(n), where n is the length of our string
Auxiliary Space – O(1).
This article is contributed by Rachit Belwariar. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Using Set() in Python Pangram Checking
- Check if a String can be converted to Pangram in K changes
- Python program to check if given string is pangram
- Missing characters to make a string Pangram
- Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes
- Anagram checking in Python using collections.Counter()
- Online algorithm for checking palindrome in a stream
- Check if a string can be split into two strings with same number of K-frequent characters
- Count of substrings having all distinct characters
- Calculate weight of parenthesis based on the given conditions
- Smallest number greater than X which is K-periodic
- Check if a given string is a Reverse Bitonic String or not
- Check if a given string is Even-Odd Palindrome or not
- Maximum time such that absolute difference between hour and minute lies in given range