Problème
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.
Contraintes
0 ≤ length ≤ 1,000
Exemples
Entrée :
text = "Never odd or even"
Sortie attendue :
expected = True
Entrée :
std::string text = "Never odd or even";
Sortie attendue :
bool expected = true;
Entrée :
string text = "Never odd or even";
Sortie attendue :
bool expected = true;
Explication
Letters only, lowercased: "neveroddoreven" reads the same both ways.
Entrée :
text = "code"
Sortie attendue :
expected = False
Entrée :
std::string text = "code";
Sortie attendue :
bool expected = false;
Entrée :
string text = "code";
Sortie attendue :
bool expected = false;
Explication
"c" and "e" differ, so it is not a palindrome.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.