Dễ 0 người đã giải Tỷ lệ chấp nhận 0%

Pangram Check

A pangram contains every English letter at least once.

Bạn sẽ học được gì

  • Collect the distinct letters of a text
  • Ignore case and non-letters
  • Compare against the 26-letter alphabet

Đề bài

Xem bản dịch

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.

Ràng buộc

0 ≤ text length ≤ 100,000. Input contains printable ASCII characters. Only letters A–Z and a–z count.

Ví dụ

Ví dụ 1
Đầu vào:
text = "The quick brown fox jumps over the lazy dog."

Kết quả mong đợi:
expected = True
Đầu vào:
std::string text = "The quick brown fox jumps over the lazy dog.";

Kết quả mong đợi:
bool expected = true;
Đầu vào:
string text = "The quick brown fox jumps over the lazy dog.";

Kết quả mong đợi:
bool expected = true;

Giải thích

Every letter from a through z appears at least once. Capital T counts as t.

Ví dụ 2
Đầu vào:
text = "abcdefghijklmnopqrstuvwxy"

Kết quả mong đợi:
expected = False
Đầu vào:
std::string text = "abcdefghijklmnopqrstuvwxy";

Kết quả mong đợi:
bool expected = false;
Đầu vào:
string text = "abcdefghijklmnopqrstuvwxy";

Kết quả mong đợi:
bool expected = false;

Giải thích

This text contains a through y, but it has no z. One missing letter makes it false.

Hướng tiếp cận

Hãy tự thử trước, sau đó mở từng gợi ý một.

Gợi ý 1

Normalize the text so letter case does not matter.

Gợi ý 2

Track which of the 26 letters have appeared at least once.

Gợi ý 3

Ignore every non-letter character completely, including spaces and punctuation.

Độ phức tạp mong đợi

O(n) time, O(1) extra space

Tham khảo

Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.

Lời giải đạt tốt nhất của mỗi người. Lời giải nhanh hơn, tốn ít bộ nhớ hơn và được đánh giá cao hơn sẽ đứng trên.

Chưa có lời giải nào đạt. Giải bài này để giành hạng nhất.

Học hỏi từ người khác

Lời giải cộng đồng

Chưa có lời giải nào được chia sẻ. Hãy giải thử thách này để đăng lời giải đầu tiên.