2068. Check Whether Two Strings are Almost Equivalent

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

On This Page

LeetCode problem 2068

class Solution:
    def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:
        cnt = Counter(word1)
        for c in word2:
            cnt[c] -= 1
        return all(abs(x) <= 3 for x in cnt.values())