2025-08-16 15:43:20 +0000 UTC
Check Whether Two Strings are Almost Equivalent
Categories:
Links
Code
class Solution:
def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:
freqs = [0] * 26
for char in word1:
freqs[ord(char) - 97] += 1
for char in word2:
freqs[ord(char) - 97] -= 1
for freq in freqs:
if freq > 3 or freq < -3:
return False
return True