Skip to content

Instantly share code, notes, and snippets.

@amraks
Created February 16, 2019 19:01
Show Gist options
  • Save amraks/323d2311d090f8488566d3c04a308065 to your computer and use it in GitHub Desktop.
Save amraks/323d2311d090f8488566d3c04a308065 to your computer and use it in GitHub Desktop.
class Solution:
def groupAnagrams(self, strs: 'List[str]') -> 'List[List[str]]':
from collections import Counter
d = {}
for s in strs:
c = ''.join(sorted(s))
if c in d:
d[c].append(s)
else:
d[c] = [s]
a = list(d.values())
return a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment