โจทย์
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
ตัวอย่าง
อินพุต:
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.
อินพุต:
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 กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน