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

Function checkNeighbors

javascript/0787-cheapest-flights-within-k-stops.js:54–64  ·  view source on GitHub ↗
(graph, cost, city, stops, seen, minHeap)

Source from the content-addressed store, hash-verified

52};
53
54var checkNeighbors = (graph, cost, city, stops, seen, minHeap) => {
55 for (let [nextCity, nextCost] of graph[city]) {
56 const hasSeen = seen.has(nextCity) && stops - 1 <= seen.get(nextCity);
57 if (hasSeen) continue;
58
59 const priority = cost + nextCost;
60 const node = [priority, nextCity, stops - 1];
61
62 minHeap.enqueue(node, priority);
63 }
64};

Callers 1

searchFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected