I don't get it, maybe I'm making some confusion but for the given string = "aaabab", your algorithm is returning 5 (the index that should be removed), but this does not makes sense since the result of this would be "aaaba" and in reverse order "abaaa". So, this is not a palindrome... Besides that, all tests cases from HackerHank passes. What I'm missing? 🤔
Instead of assigning indexToRemove to right directly in the else branch, I suspect it should be checked if the string from left to right-1 is a palindrome. If it is not (as in the test case in your comment), then indexToRemove should remain equal to -1. The loop can still break since the input cannot be made palindrome by removing only one character.
I have the same result with you. Lets say the string is "abxca", the algorithm from video outputs as 3 which we remove third char it is abxa which is not a palindrome. hacker rank reports 100% which is not true. I think they should enrich the test cases @@CalebeMachado
Hi man, I'm curious about something that happens to me with this challenge. Using your solution or another one of my design, all the tests pass. However, tests 12 and 13 fail if I solve this challenge in a mock test. Do you know why? Cheers.