Skip to content

Commit 62307d4

Browse files
committed
feat: 그룹 애나그램 풀이
1 parent 12c77c0 commit 62307d4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

group-anagrams/saysimple.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+
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
5+
d = defaultdict(list)
6+
for s in strs:
7+
if not s:
8+
d["0"].append("")
9+
else:
10+
d["".join(sorted(s))].append(s)
11+
12+
return [d[s] for s in d]

0 commit comments

Comments
 (0)