标签:
这道题就是简单的哈希表了
from collections import defaultdict class Solution: # @param {string[]} strs # @return {string[]} def anagrams(self, strs): dic = defaultdict(list) ans = [] for s in strs: dic["".join(sorted(s))].append(s) for v in dic.values(): if len(v) > 1: ans.extend(v) return ans
标签:
原文地址:http://www.cnblogs.com/dapanshe/p/4650031.html