-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
For https://neetcode.io/problems/valid-palindrome-ii
The following code is accepted
class Solution:
def validPalindrome(self, s: str) -> bool:
i = 0
j = len(s) -1
missing = False
while(i < j):
f = s[i]
b = s[j]
if f == b:
i += 1
j -= 1
elif missing:
return False
elif f == s[j-1]:
missing = True
i += 1
j -= 2
elif s[i+1] == b:
missing = True
i += 2
j -= 1
else:
return False
return True
but fails the test case s="eceec" (is false but should be true)
Metadata
Metadata
Assignees
Labels
No labels