Tutte le sfide
Media 0 risolte 0% di accettazione

Recursive Palindrome

Check a palindrome recursively, ignoring case and punctuation.

Problema

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.

Vincoli

0 ≤ length ≤ 1,000

Esempi

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

Output atteso:
expected = True
Input:
std::string text = "Never odd or even";

Output atteso:
bool expected = true;
Input:
string text = "Never odd or even";

Output atteso:
bool expected = true;

Spiegazione

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

Esempio 2
Input:
text = "code"

Output atteso:
expected = False
Input:
std::string text = "code";

Output atteso:
bool expected = false;
Input:
string text = "code";

Output atteso:
bool expected = false;

Spiegazione

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

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.