Created
February 16, 2019 19:01
-
-
Save amraks/323d2311d090f8488566d3c04a308065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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