educative.io

Think this solution might need to be revisited

I’ve found that the solution for this problem is partially incorrect. When passing the string “toot” to the function, it returns false, which is incorrect. From debugging, I’ve found that, in the case that the string has even letters like “toot”, the way the code is structured in the solution will falsely return false at line 4. However, after successful recursive calls, if the text eventually ends up an empty string, that should be grounds for a found palindrome. Maybe getting rid of lines 4-6 and changing line 7 to (if text.length() <= 1) return true;


Course: Recursion for Coding Interviews in Java - Learn Interactively
Lesson: Solution Review: Is this String a Palindrome? - Recursion for Coding Interviews in Java

Hello @Elliot_C_Hannah_III,
Thank you for pointing this out. The changes have been made.