Skip to content

Commit e9282ac

Browse files
authored
Merge pull request #2 from Bumsu-Yi/main
4th problem
2 parents f0f6b73 + 22eaaba commit e9282ac

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sam_lee/Group_Anagrams.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+
anagrams = defaultdict(list)
6+
7+
for word in strs:
8+
anagrams[str(sorted(word))].append(word)
9+
10+
return anagrams.values()
11+
12+

0 commit comments

Comments
 (0)