ปานกลาง 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Recursive Palindrome

Check a palindrome recursively, ignoring case and punctuation.

โจทย์

Decide whether text reads the same forwards and backwards, considering only letters and digits and ignoring case. Solve it recursively: compare the outer characters, then check the inside.

Implement is_palindrome_recursive(text).

Input

text: The text to check (ASCII characters).

Output

Return true for a palindrome, otherwise false.

เงื่อนไข

0 ≤ length ≤ 1,000

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
text = "Never odd or even"

ผลลัพธ์ที่คาดหวัง:
expected = True
อินพุต:
std::string text = "Never odd or even";

ผลลัพธ์ที่คาดหวัง:
bool expected = true;
อินพุต:
string text = "Never odd or even";

ผลลัพธ์ที่คาดหวัง:
bool expected = true;

คำอธิบาย

Letters only, lowercased: "neveroddoreven" reads the same both ways.

ตัวอย่างที่ 2
อินพุต:
text = "code"

ผลลัพธ์ที่คาดหวัง:
expected = False
อินพุต:
std::string text = "code";

ผลลัพธ์ที่คาดหวัง:
bool expected = false;
อินพุต:
string text = "code";

ผลลัพธ์ที่คาดหวัง:
bool expected = false;

คำอธิบาย

"c" and "e" differ, so it is not a palindrome.

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก