We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java
public static boolean checkPangram(String str) {
// Normalize the string to lowercase and remove non-letter characters
String normalizedStr = str.toLowerCase().replaceAll("[^a-z]", "");
// Use a set to track unique letters
HashSet<Character> lettersSet = new HashSet<>();
// Add each character to the set
for (char c : normalizedStr.toCharArray()) {
lettersSet.add(c);
}
// Check if the size of the set is 26 (number of letters in the alphabet)
return lettersSet.size() == 26;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pangrams
You are viewing a single comment's thread. Return to all comments →
}