Published: 15 Feb 2024 › Updated: 15 Feb 2024
Codewars 6 kyu Kata: Detect Pangram
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;
}
}
Leave Codewars 6 kyu Kata: Detect Pangram to:
Read more #hive-155735 posts
Best Posts From Lochard
We have not curated any of lochard's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Lochard
- King's Cross - 45th month of persecution by CCP, LT &UK
- 43rd month, belongings stolen
- Another round of strong damage
- 41st month of humiliation, torture and other crimes
- This is not a prank
- How sick one has to be to take pleasure in drugging and indirectly molesting others?
- Has AI already surpassed humans in morality and emotion?
- Just a reminder that your fellow biped had been treated as non-human for 39 months
- Psychopathy (Chat with AI)
- [Solved] Oracle Linux 10 WiFi adpator not found
- Do you get drugged every day?
- 39th month treated as non-human
- Generated Art (Warning: Disturbing, death symbolism)
- Requesting information about crimes committed by the police
- What are they? What am I?
- Wth is with the world nowadays?
- Everyday being put under effects by devices and substances
- 38th month treated as non-human
- If these define human
- Before: "Are they really police?"; Now: "No wonder."