C
case.learning
Hi everyone,
I'm a C++ novice. I'm trying to learn recursion and have written this
piece of code but it doesn't work. Could you help me to see where it
goes wrong? Thanks.
bool PalindromeHelper(string s)
{
int len = s.length();
if (len == 1 || len == 0)
return true;
else
return (s[0] == s[len-1]) &&
PalindromeHelper(s.substr(1, len-2));
}
I'm a C++ novice. I'm trying to learn recursion and have written this
piece of code but it doesn't work. Could you help me to see where it
goes wrong? Thanks.
bool PalindromeHelper(string s)
{
int len = s.length();
if (len == 1 || len == 0)
return true;
else
return (s[0] == s[len-1]) &&
PalindromeHelper(s.substr(1, len-2));
}