Skip to content

Commit d81cc20

Browse files
committed
feat: Solve group-anagrams problem
1 parent fc48533 commit d81cc20

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

group-anagrams/hu6r1s.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from collections import defaultdict
2+
3+
class Solution:
4+
"""
5+
1. 정렬된 값이 딕셔너리에 있으면 리스트 형식으로 삽입
6+
"""
7+
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
8+
dict_strs = defaultdict(list)
9+
10+
for word in strs:
11+
dict_strs[str(sorted(word))].append(word)
12+
return list(dict_strs.values())

0 commit comments

Comments
 (0)