forked from onlybooks/python-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5-1.py
More file actions
12 lines (9 loc) · 348 Bytes
/
5-1.py
File metadata and controls
12 lines (9 loc) · 348 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
import collections
from typing import List
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
anagrams = collections.defaultdict(list)
for word in strs:
# 정렬하여 딕셔너리에 추가
anagrams[''.join(sorted(word))].append(word)
return list(anagrams.values())