Skip to content

Commit 448c105

Browse files
committed
Week 5
1 parent 7c25530 commit 448c105

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

group-anagrams/8804who.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
3+
dic=defaultdict(list)
4+
for string in strs:
5+
sorted_str = ''.join(sorted(string))
6+
dic[sorted_str].append(string)
7+
8+
return list(dic.values())

0 commit comments

Comments
 (0)