โจทย์
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
ทำให้ข้อความเป็นมาตรฐานเดียวกันเพื่อไม่ให้ตัวพิมพ์เล็กใหญ่มีผล
คำใบ้ 2
ติดตามว่า 26 ตัวอักษรมีตัวไหนปรากฏแล้วบ้าง
คำใบ้ 3
ข้ามอักขระที่ไม่ใช่ตัวอักษรทั้งหมด รวมถึงช่องว่างและเครื่องหมายวรรคตอน
ความซับซ้อนที่คาดหวัง
เวลา O(n), หน่วยความจำเพิ่ม O(1)
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน