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 2fd0eef commit 35e0c54Copy full SHA for 35e0c54
valid-anagram/thispath98.py
@@ -0,0 +1,31 @@
1
+
2
+class Solution:
3
+ def isAnagram(self, s: str, t: str) -> bool:
4
+ """
5
+ Time Complexity:
6
+ O(N log N):
7
+ 두 string을 정렬, 이는 보통 quick sort로 구현되어
8
+ N log N 만큼 소요된다.
9
10
+ Space Complexity:
11
+ O(N):
12
+ 최악의 경우 (모든 string이 유일할 경우) N개의 리스트
13
+ 를 저장한다.
14
15
+ return sorted(s) == sorted(t)
16
17
+ def isAnagramCounter(self, s: str, t: str) -> bool:
18
19
20
21
+ 해시를 기반으로 일치 여부 탐색, N개의 엔트리를
22
+ 한번씩 순회하는 것으로 구현된다.
23
24
25
26
27
28
29
+ from collections import Counter
30
31
+ return Counter(s) == Counter(t)
0 commit comments