![]() |
VOOZH | about |
Given a string Str. The task is to check if it is Pangram or not.
A pangram is a sentence containing every letter in the English Alphabet.
Examples:
Input: "The quick brown fox jumps over the lazy dog"
Output: is a Pangram
Explanation: Contains all the characters from βaβ to βzβ]Input: "The quick brown fox jumps over the dog"
Output: is not a Pangram
Explanation: Doesnβt contain all the characters from βaβ to βzβ, as βlβ, βzβ, βyβ are missing
Approach: Below is the idea to solve the problem
Create a mark[] array of Boolean types and iterate through all the characters of the string and mark it as visited. 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 check whether all the characters are marked or not. If not then return false as this is not a pangram else return true.
Follow the below steps to Implement the idea:
Below is the Implementation of above approach
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), as 26 size Boolean vector is constant.