5 line python code


#1
def anagrams(self, A):
        d = defaultdict(list)
        for i in range(len(A)):
            d["".join(sorted(A[i]))].append(i+1)
        return [v for k,v in d.items()]