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.
Einschränkungen
0 ≤ length ≤ 1,000
Beispiele
Eingabe:
text = "Never odd or even"
Erwartete Ausgabe:
expected = True
Eingabe:
std::string text = "Never odd or even";
Erwartete Ausgabe:
bool expected = true;
Eingabe:
string text = "Never odd or even";
Erwartete Ausgabe:
bool expected = true;
Erläuterung
Letters only, lowercased: "neveroddoreven" reads the same both ways.
Eingabe:
text = "code"
Erwartete Ausgabe:
expected = False
Eingabe:
std::string text = "code";
Erwartete Ausgabe:
bool expected = false;
Eingabe:
string text = "code";
Erwartete Ausgabe:
bool expected = false;
Erläuterung
"c" and "e" differ, so it is not a palindrome.
Referenzen
Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.