java
class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
Map<String, List<String>> map = new HashMap<>();
for (String str : strs) {
String hash = getHash(str);
map.computeIfAbsent(hash, k -> new ArrayList<>()).add(str);
}
return new ArrayList<>(map.values());
}
public String getHash(String str) {
char[] array = str.toCharArray();
Arrays.sort(array);
return String.valueOf(array);
}
}