11.2 Write a method to sort an array of strings so that all the anagrams are next to each other.
解法一:
另一種解法較為複雜一些,用到了哈希表來建立排序後的字元串和其所有的異位詞集合的映射,最後在按集合填充原數組,參見代碼如下:
解法二:
11.2 Write a method to sort an array of strings so that all the anagrams are next to each other.
解法一:
另一種解法較為複雜一些,用到了哈希表來建立排序後的字元串和其所有的異位詞集合的映射,最後在按集合填充原數組,參見代碼如下:
解法二: