2068. Check Whether Two Strings are Almost Equivalent

Обновлено: 2024-03-12
1 мин
[]

Содержание

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())