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

Function getFrequencyMap

javascript/0621-task-scheduler.js:15–23  ·  view source on GitHub ↗
(tasks, frequencyMap = new Array(26).fill(0))

Source from the content-addressed store, hash-verified

13};
14
15var getFrequencyMap = (tasks, frequencyMap = new Array(26).fill(0)) => {
16 for (const task of tasks) {
17 const index = task.charCodeAt(0) - 'A'.charCodeAt(0);
18
19 frequencyMap[index]++;
20 }
21
22 return frequencyMap;
23};
24
25const getMaxHeap = (frequencyMap, maxHeap = new MaxPriorityQueue()) => {
26 for (const frequency of frequencyMap) {

Callers 1

leastIntervalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected