MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / groupWords

Function groupWords

javascript/0049-group-anagrams.js:17–26  ·  view source on GitHub ↗
(words, map)

Source from the content-addressed store, hash-verified

15};
16
17var groupWords = (words, map) => {
18 for (const original of words) {
19 /* Time O(N) */
20 const sorted = reorder(original); /* Time O(K * log(K)) | Space O(K) */
21 const values = map.get(sorted) || [];
22
23 values.push(original); /* | Space O(N) */
24 map.set(sorted, values); /* | Space O(N * K) */
25 }
26};
27
28const reorder = (str) =>
29 str

Callers 1

groupAnagramsFunction · 0.85

Calls 5

getHashFunction · 0.85
reorderFunction · 0.70
getMethod · 0.45
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected