my python solution


  • 0
    M

    class Solution(object):

    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        d=collections.defaultdict(list)
        for i in strs:
            s=''.join(sorted([x for x in i]))
            d[s].append(i)
        l=[sorted(d[k]) for k in d.keys()]
        return l

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.