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.
解法一:
另一种解法较为复杂一些,用到了哈希表来建立排序后的字符串和其所有的异位词集合的映射,最后在按集合填充原数组,参见代码如下:
解法二: