You are viewing a single comment's thread. Return to all comments →
My Python solution doesn't pass many of the testcases! Can anyone help?
def ispalindrome(s): if s[::-1] == s: return True return False def palindromeIndex(s): s = list(s) if ispalindrome(s): return -1 for i in range(len(s) // 2 + 1): if ispalindrome(s[:i] + s[i + 1:]): return i if ispalindrome(s[:len(s) - i - 1] + s[len(s) - i:]): return len(s) - i - 1 return -1
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 →
My Python solution doesn't pass many of the testcases! Can anyone help?