๐๋ฌธ์ ํ์ด
1. collections.defaultdict()๋ฅผ ํ์ฉํ์ฌ ๋น ๋์ ๋๋ฆฌ ์์ฑ ํ append๋ก ์์ ์ถ๊ฐ
class Solution(object):
def groupAnagrams(self, strs):
anagrams = collections.defaultdict(list)
for word in strs:
sorted_word = ''.join(sorted(word))
anagrams[sorted_word].append(word)
return list(anagrams.values())