提交:O(N) O(1)
class Solution: def validPalindrome(self, s: str) -> bool: def helper(s): if s == s[::-1]: return True return False l,r = 0,len(s) - 1 while l < r : if s[l] == s[r]: l += 1 r -= 1 else: if helper(s[l+1:r+1]) or helper(s[l:r]): return True return False return True
原文:https://www.cnblogs.com/oldby/p/12919412.html