Skip to content

Commit ed2f5d6

Browse files
authored
Bug fix: Defined as char however should be int
There was a small typo on Line 8 defining the array as char instead of int. This resulted in a permanent blank array as the ++ increment is an integer value and couldn't be stored.
1 parent 8d7da5b commit ed2f5d6

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)