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.
Can't for the life of me figure out what's wrong with my solution - it passes 12/15 test cases.
def palindromeIndex(s):
for i in range(len(s) // 2):
j = len(s) - 1 - i
if (s[i] == s[j]):
continue
if (s[i] == s[j - 1]):
return j
if (s[i + 1] == s[j]):
return i
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 →
Can't for the life of me figure out what's wrong with my solution - it passes 12/15 test cases.