Leetcode - 1832. Check if the Sentence Is Pangram
Leetcode - 1832. Check if the Sentence Is Pangram
A pangram is a sentence where every letter of the English alphabet appears at least once.
Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.
Solution
1
2
3
4
5
6
7
8
9
10
11
func checkIfPangram(sentence string) bool {
charMap := make(map[rune]bool)
for _, char := range strings.ToLower(sentence){
if unicode.IsLetter(char){
charMap[char]=true
}
}
return len(charMap)==26
}
This post is licensed under CC BY 4.0 by the author.