MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / groupAnagrams

Method groupAnagrams

Array/GroupAnagrams.py:31–46  ·  view source on GitHub ↗

:type strs: List[str] :rtype: List[List[str]]

(self, strs)

Source from the content-addressed store, hash-verified

29"""
30class Solution(object):
31 def groupAnagrams(self, strs):
32 """
33 :type strs: List[str]
34 :rtype: List[List[str]]
35 """
36 result = {}
37
38 for i in strs:
39 key = ''.join(sorted(i))
40
41 try:
42 result[key].append(i)
43 except:
44 result[key] = [i]
45
46 return result.values()
47

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected