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

Function dfs

javascript/0261-graph-valid-tree.js:35–42  ·  view source on GitHub ↗
(node, graph, visited)

Source from the content-addressed store, hash-verified

33};
34
35const dfs = (node, graph, visited) => {
36 if (visited.has(node)) return;
37 visited.add(node);
38
39 for (const neighbor of graph[node]) {
40 dfs(neighbor, graph, visited);
41 }
42};
43
44/**
45 * https://leetcode.com/problems/graph-valid-tree/

Callers 1

validTreeFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected