We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- Prepare
- Algorithms
- Strings
- Palindrome Index
- Discussions

# Palindrome Index

# Palindrome Index

#### Sort by

recency

#### |

#### 1074 Discussions

#### |

Please Login in order to post a comment

Here is my c++ solution : explanation here https://youtu.be/QjHpvMdfnqs,

I figure if you just check two characters on from the two indexes you can be certain which character is the baddie. You can't do that just by checking one. Not 100% sure if this passes by some fluke though. Solution is pretty much O(n) for time and O(1) for memory.

I was scratching my head on this problem for a while. I was stuck on my idea that "abbauiop" would be a palindrome (abba). And therefore you would need to find the midpoint of the palindrome section in order to know what it is mirrored around. However, in this problem. It asks for a palindrome to be made by removing 1 character:

In my example the output should be -1 because a palindrome cannot be made by removing 1 value from the string

## Java