Problem link
https://leetcode.com/problems/group-anagrams/
Problem Summary
anagram이 같은 단어끼리 모아서 출력하는 문제.
Solution
정렬한 문자열이 같은 문자열들끼리 묶은 다음 출력하면 된다.
Source Code
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
map = defaultdict(list)
for s in strs:
map[str(sorted(s))].append(s)
return map.values()