Group Anagrams in Elixir: A Concise Solution
def group_anagrams(strs) mp = {} for str in strs do key = str.chars.sort.join mp[key] ||= [] mp[key] << str end ans = [] mp.each do |key, value| ans << value end ans end
原文地址: https://www.cveoy.top/t/topic/qdAr 著作权归作者所有。请勿转载和采集!