Đề bài
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.
Ràng buộc
0 ≤ length ≤ 1,000
Ví dụ
Đầu vào:
text = "Never odd or even"
Kết quả mong đợi:
expected = True
Đầu vào:
std::string text = "Never odd or even";
Kết quả mong đợi:
bool expected = true;
Đầu vào:
string text = "Never odd or even";
Kết quả mong đợi:
bool expected = true;
Giải thích
Letters only, lowercased: "neveroddoreven" reads the same both ways.
Đầu vào:
text = "code"
Kết quả mong đợi:
expected = False
Đầu vào:
std::string text = "code";
Kết quả mong đợi:
bool expected = false;
Đầu vào:
string text = "code";
Kết quả mong đợi:
bool expected = false;
Giải thích
"c" and "e" differ, so it is not a palindrome.
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.