Skip to content

Instantly share code, notes, and snippets.

@rejoycesong
Created April 7, 2020 00:41
Show Gist options
  • Save rejoycesong/8a28e68f5dc420b7f6b5fd9312bc1dac to your computer and use it in GitHub Desktop.
Save rejoycesong/8a28e68f5dc420b7f6b5fd9312bc1dac to your computer and use it in GitHub Desktop.
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
seen = {}
for s in strs:
word = ''.join(sorted(s))
if word in seen:
seen[word].append(s)
else:
seen[word] = [s]
return seen.values()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment