We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8944b67 commit 7262bb7Copy full SHA for 7262bb7
group-anagrams/river20s.py
@@ -0,0 +1,14 @@
1
+import collections
2
+from typing import List
3
+
4
+class Solution(object):
5
+ def groupAnagrams(self, strs):
6
+ """
7
+ :type strs: List[str]
8
+ :rtype: List[List[str]]
9
10
+ anagram_groups = collections.defaultdict(list)
11
+ for s in strs:
12
+ key = tuple(sorted(s))
13
+ anagram_groups[key].append(s)
14
+ return list(anagram_groups.values())
0 commit comments