0% completed
Pangram (easy)
On This Page
Problem Statement
Try it yourself
Problem Statement
A pangram is a sentence where every letter of the English alphabet appears at least once.
Given a string sentence containing English letters (lower or upper-case), return true if sentence is a pangram, or false otherwise.
Note: The given sentence might contain other characters like digits or spaces, your solution should handle these too.
Example 1:
Input: sentence = "TheQuickBrownFoxJumpsOverTheLazyDog"
Output: true
Explanation: The sentence contains at least one occurrence of every letter of the English alphabet either in lower or upper case.
Example 2:
Input: sentence = "This is not a pangram"
Output: false
Explanation: The sentence doesn't contain at least one occurrence of every letter of the English alphabet.
Example 3:
Input: sentence = "abcdefghijklmnopqrstuvwxy1"
Output: false
Explanation: The digit is not a letter, so it does not count towards the alphabet. Only a through y are
present and z is missing, so this is not a pangram.
Constraints:
1 <= sentence.length <= 1000sentenceconsists of printable ASCII characters, which may include letters, digits and spaces.
Try it yourself
Try solving this question here:
Edris
· 8 days ago
Keeping it simple.
class Solution { public boolean checkIfPangram(String sentence) { // TODO: Write your code here Set<Character> mySet = new HashSet<>();
sentence = sentence.toLowerCase();
for (int i = 0; i < sentence.length(); i++) { if (sentence.charAt(i) >= 97 && sentence.charAt(i) <= 122) { mySet.add(sentence.charAt(i)); } }
return mySet.size() == 26; } }
Nyan Htet
· a month ago
With JS I used a Set and since there are non alphabetical characters in the test cases I also used regex to check each character: /[a-zA-Z]/g
nayak.bishwa
· 5 months ago
"TheQuickBrownFoxJumpsOverTheLazyDog"
Here o in Brown and Fox and Dog, Still the expected output is true, how this could possible?
Reading Progress
0%
On This Page
Problem Statement
Try it yourself