All challenges
Medium 0 solved 0% acceptance

Recursive Palindrome

Check a palindrome recursively, ignoring case and punctuation.

Problem

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.

Constraints

0 ≤ length ≤ 1,000

Examples

Example 1
Input:
text = "Never odd or even"

Expected output:
expected = True
Input:
std::string text = "Never odd or even";

Expected output:
bool expected = true;
Input:
string text = "Never odd or even";

Expected output:
bool expected = true;

Explanation

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

Example 2
Input:
text = "code"

Expected output:
expected = False
Input:
std::string text = "code";

Expected output:
bool expected = false;
Input:
string text = "code";

Expected output:
bool expected = false;

Explanation

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

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.