解题思路
Map
public List<List<String>> groupAnagrams(String[] strs){
if(strs.length == 0)
return new ArrayList<>();
Map<String,List> ans = new HashMap<>();
for(String s:strs){
char[] ca = s.toCharArray();
Arrays.sort(ca);
String key = String.valueOf(ca);
if(!ans.containsKey(key))
ans.put(key,new ArrayList());
ans.get(key).add(s);
}
return new ArrayList(ans.values());
}