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

Function checkNeighbors

javascript/0743-network-delay-time.js:47–58  ·  view source on GitHub ↗
(queue, graph, maxTime)

Source from the content-addressed store, hash-verified

45};
46
47var checkNeighbors = (queue, graph, maxTime) => {
48 const [node, time] = queue.dequeue();
49
50 const canUpdate = time < maxTime[node];
51 if (!canUpdate) return;
52
53 maxTime[node] = time;
54
55 for (const [dst, weight] of graph[node]) {
56 queue.enqueue([dst, weight + time]);
57 }
58};
59
60var checkAns = (maxTime) => {
61 const max = Math.max(...maxTime);

Callers 2

bfsFunction · 0.70
getTimeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected