Skip to content

Commit 38f42a2

Browse files
author
jinbeom
committed
Group Anagrams Solution
1 parent 136a246 commit 38f42a2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

group-anagrams/kayden.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# 시간복잡도: O(N)
2+
# 공간복잡도: O(N)
3+
class Solution:
4+
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
5+
groups = {}
6+
for anagram in strs:
7+
key = str(sorted(anagram))
8+
groups.setdefault(key, []).append(anagram)
9+
10+
return list(groups.values())

0 commit comments

Comments
 (0)