Python 4 lines, easy to understand


  • 0
    N
        def groupAnagrams(self, strs):
            d = defaultdict(list)
            for s in strs:
                d[''.join(sorted(s))].append(s)
            return d.values()
    

Log in to reply
 

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