49. 字母异位词分组

class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        word = {}
        for str in strs:
            key = ''.join(sorted(str))
            if key in word.keys():
                word[key].append(str)
            else:
                word[key] = [str]
        res = []
        for value in word.values():
            res.append(value)
        return res

©️2020 CSDN 皮肤主题: 游动-白 设计师:上身试试 返回首页