Trung bình 0 đã giải Tỷ lệ chấp nhận 0%

Recursive Palindrome

Check a palindrome recursively, ignoring case and punctuation.

Đề 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ụ

Ví dụ 1
Đầ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.

Ví dụ 2
Đầ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.

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

Giải pháp cộng đồng

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