Find what makes string not a palindrome?
Yesterday, my friend Manoj asked me this interesting question. The problem statement is as follows,
If I give you a string, say S = "madam" which is palindrome. But now, I have added few extra charater to S [You don't know how many charaters] and now S = "mPadam". I have added 'P' in this case. You have to come up with a linear time algorith i.e. O(n) and find out if I have added 1 charater or more to the original palindrome string S.
- If I have added 1 extra charater then print that extra charater
- If I have added more than one extra charater then exit the program