Created
April 7, 2020 00:41
-
-
Save rejoycesong/8a28e68f5dc420b7f6b5fd9312bc1dac 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]]: | |
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