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 4803e42 commit c00f407Copy full SHA for c00f407
valid-anagram/jinah92.py
@@ -0,0 +1,13 @@
1
+# 공간복잡도: O(n), 시간복잡도: O(n)
2
+class Solution:
3
+ def isAnagram(self, s: str, t: str) -> bool:
4
+ char_set_1, char_set_2 = {}, {}
5
+
6
+ for ch in s:
7
+ char_set_1[ch] = 0 if ch not in char_set_1 else char_set_1[ch] + 1
8
9
+ for ch in t:
10
+ char_set_2[ch] = 0 if ch not in char_set_2 else char_set_2[ch] + 1
11
12
+ # dictionary의 모든 요소 종류와 개수가 일치해야 함
13
+ return char_set_1 == char_set_2
0 commit comments