Skip to content

Commit 082d637

Browse files
authored
Create twostring.py
1 parent 1e9e319 commit 082d637

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

python/leetcode/twostring.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution:
2+
def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:
3+
A = [0] * 26
4+
for char in word1: A[ord(char) - ord("a")] += 1
5+
for char in word2: A[ord(char) - ord("a")] -= 1
6+
return not any ([(f < -3 or f > 3) for f in A])

0 commit comments

Comments
 (0)