2330. Valid Palindrome IV

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2330

class Solution:
    def makePalindrome(self, s: str) -> bool:
        i, j = 0, len(s) - 1
        cnt = 0
        while i < j:
            cnt += s[i] != s[j]
            i, j = i + 1, j - 1
        return cnt <= 2