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

Function checkNeighbor

javascript/0261-graph-valid-tree.js:91–100  ·  view source on GitHub ↗
(graph, visited, queue)

Source from the content-addressed store, hash-verified

89};
90
91const checkNeighbor = (graph, visited, queue) => {
92 const node = queue.dequeue();
93
94 for (const neighbor of graph[node]) {
95 if (visited.has(neighbor)) continue;
96 visited.add(neighbor);
97
98 queue.enqueue(neighbor);
99 }
100};
101
102/**
103 * https://leetcode.com/problems/graph-valid-tree/

Callers 1

bfsFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected