Skip to content

Commit 7881255

Browse files
authored
Merge pull request #2190 from OfficialTomJ/patch-1
Bug fix: Defined as char however should be int - Java
2 parents f714f82 + ed2f5d6 commit 7881255

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: java/0049-group-anagrams.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ public List<List<String>> groupAnagrams(String[] strs) {
55
if (strs.length == 0) return res;
66
HashMap<String, List<String>> map = new HashMap<>();
77
for (String s : strs) {
8-
char[] hash = new char[26];
8+
int[] hash = new int[26];
99
for (char c : s.toCharArray()) {
1010
hash[c - 'a']++;
1111
}
12-
String key = new String(hash);
12+
String key = new String(Arrays.toString(hash));
1313
map.computeIfAbsent(key, k -> new ArrayList<>());
1414
map.get(key).add(s);
1515
}

0 commit comments

Comments
 (0)