diff --git a/python3/242/242-valid-anagram-b.py b/python3/242/242-valid-anagram-b.py index 78c6a5e..00d2fcd 100644 --- a/python3/242/242-valid-anagram-b.py +++ b/python3/242/242-valid-anagram-b.py @@ -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())