Skip to content

Commit

Permalink
242: Simplify for-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
donjuardo committed Jul 10, 2024
1 parent 5c72d3c commit dd13bf8
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions python3/242/242-valid-anagram-b.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ def isAnagram(self, s: str, t: str) -> bool:
count = {}

for i, c in enumerate(s):
if count.get(c) is not None:
count[c] += 1
else:
count[c] = 1
if count.get(t[i]) is not None:
count[t[i]] -= 1
else:
count[t[i]] = -1
count[c] = count.get(c, 0) + 1
count[t[i]] = count.get(t[i], 0) - 1

return not any(count.values())

0 comments on commit dd13bf8

Please sign in to comment.