We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f714f82 + ed2f5d6 commit 7881255Copy full SHA for 7881255
java/0049-group-anagrams.java
@@ -5,11 +5,11 @@ public List<List<String>> groupAnagrams(String[] strs) {
5
if (strs.length == 0) return res;
6
HashMap<String, List<String>> map = new HashMap<>();
7
for (String s : strs) {
8
- char[] hash = new char[26];
+ int[] hash = new int[26];
9
for (char c : s.toCharArray()) {
10
hash[c - 'a']++;
11
}
12
- String key = new String(hash);
+ String key = new String(Arrays.toString(hash));
13
map.computeIfAbsent(key, k -> new ArrayList<>());
14
map.get(key).add(s);
15
0 commit comments