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.
1 parent 8f6c82f commit e4aaeabCopy full SHA for e4aaeab
group-anagrams/gwbaik9717.js
@@ -11,13 +11,16 @@ var groupAnagrams = function (strs) {
11
const anagramDict = new Map();
12
13
const getKey = (str) => {
14
+ const minCharCode = "a".charCodeAt();
15
+ const maxCharCode = "z".charCodeAt();
16
+
17
const counter = Array.from(
- { length: "z".charCodeAt() - "a".charCodeAt() + 1 },
18
+ { length: maxCharCode - minCharCode + 1 },
19
() => 0
20
);
21
22
for (const chr of str) {
- const index = chr.charCodeAt() - "a".charCodeAt();
23
+ const index = chr.charCodeAt() - minCharCode;
24
counter[index]++;
25
}
26
0 commit comments