49 Given an array of strings, return all groups of strings that are anagrams.
public List<String> anagrams(String[] strs) {
HashMap<String, List<String>> map = new HashMap<>();
for (int i = 0; i < strs.length; i++){
char[] tmp = strs[i].toCharArray();
Arrays.sort(tmp);
String key = new String(tmp);
if (!map.containsKey(key)){
map.put(key, new ArrayList<String>());
}
map.get(key).add(strs[i]);
}
List<String> ans = new ArrayList<>();
for (List<String> tmp : map.values()){
if (tmp.size() >= 2){
ans.addAll(tmp);
}
}
return ans;
}