We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9ae750 commit a64b61fCopy full SHA for a64b61f
valid-anagram/hajunyoo.py
@@ -0,0 +1,25 @@
1
+from collections import defaultdict
2
+
3
4
+class Solution:
5
+ def isAnagram(self, s: str, t: str) -> bool:
6
+ char_map = defaultdict(int)
7
+ for s1 in s:
8
+ char_map[s1] += 1
9
10
+ contrast_map = defaultdict(int)
11
+ for t1 in t:
12
+ contrast_map[t1] += 1
13
14
+ for key, val in char_map.items():
15
+ contrast_val = contrast_map[key]
16
+ if contrast_val != val:
17
+ return False
18
19
+ for key, val in contrast_map.items():
20
+ char_val = char_map[key]
21
+ if char_val != val:
22
23
24
+ return True
25
0 commit comments