問題
A pangram contains every English letter at least once. Determine whether the text is a pangram. Ignore case, spaces, digits, and punctuation.
Implement pangram_check(text).
Input
text: The text to inspect.
Output
Return true if all 26 letters appear, otherwise false.
制約
0 ≤ text length ≤ 100,000. Input contains printable ASCII characters. Only letters A–Z and a–z count.
例
入力:
text = "The quick brown fox jumps over the lazy dog."
期待される出力:
expected = True
入力:
std::string text = "The quick brown fox jumps over the lazy dog.";
期待される出力:
bool expected = true;
入力:
string text = "The quick brown fox jumps over the lazy dog.";
期待される出力:
bool expected = true;
解説
Every letter from a through z appears at least once. Capital T counts as t.
入力:
text = "abcdefghijklmnopqrstuvwxy"
期待される出力:
expected = False
入力:
std::string text = "abcdefghijklmnopqrstuvwxy";
期待される出力:
bool expected = false;
入力:
string text = "abcdefghijklmnopqrstuvwxy";
期待される出力:
bool expected = false;
解説
This text contains a through y, but it has no z. One missing letter makes it false.
解き方のヒント
まずは自分で考えてから、ヒントを 1 つずつ開いてみましょう。
ヒント 1
大文字小文字を気にしないよう、文字列を正規化する。
ヒント 2
26文字がそれぞれ少なくとも1回出たかを記録する。
ヒント 3
空白や句読点を含む非アルファベット文字はすべて無視する。
目安の計算量
時間 O(n)、追加メモリ O(1)
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。