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.
The best way to solve this problem is by looking at it from both ends just like you would while checking for the string being a palindrome. When an inequality occurs,
->skip the right element and check the middle portion of the string including the left element if it's a palindrome.
->if a palindrome index of right element should be skipped
->else index of left element should be skipped
If no inequaliry occured then return -1.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Palindrome Index
You are viewing a single comment's thread. Return to all comments →
The best way to solve this problem is by looking at it from both ends just like you would while checking for the string being a palindrome. When an inequality occurs, ->skip the right element and check the middle portion of the string including the left element if it's a palindrome. ->if a palindrome index of right element should be skipped ->else index of left element should be skipped If no inequaliry occured then return -1.