HomeValid Palindrome IV 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution: def makePalindrome(self, s: str) -> bool: l = 0 r = len(s) - 1 cnt = 0 while l < r: if s[l] != s[r]: cnt += 1 if cnt > 2: return False l += 1 r -= 1 return True
1 2 3 4 5 6 7 8 9 10 11 12 13
class Solution: def makePalindrome(self, s: str) -> bool: l = 0 r = len(s) - 1 cnt = 0 while l < r: if s[l] != s[r]: cnt += 1 if cnt > 2: return False l += 1 r -= 1 return True