my little repo of code solutions to code challenges on GitHub
A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant).
Given a string, detect whether or not it is a pangram. Return True if it is, False if not. Ignore numbers and punctuation.
import java.util.*;
public class PangramChecker
{
public boolean check( String sentence )
{
HashSet< Character > ans =
new HashSet<>();
HashSet< Character > chars =
new HashSet<>();
sentence = sentence.toUpperCase();
for ( char ch = 'A'; ch <= 'Z'; ch++ )
{
chars.add( ch );
}
for ( Character ch : sentence.toCharArray() )
{
if ( chars.contains( ch ) )
{
ans.add( ch );
}
}
return ans.size() == 26;
}
}