Skip to content

Commit 22eaaba

Browse files
committed
4th problem
1 parent 786a470 commit 22eaaba

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)