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

Function hasRedundantConnection

javascript/0684-redundant-connection.js:20–28  ·  view source on GitHub ↗
(graph, source, target, seen = new Set())

Source from the content-addressed store, hash-verified

18};
19
20const hasRedundantConnection = (graph, source, target, seen = new Set()) => {
21 if (seen.has(source)) return false;
22 seen.add(source);
23
24 const isEqual = source === target;
25 if (isEqual) return true;
26
27 return dfs(graph, source, target, seen);
28};
29
30const dfs = (graph, source, target, seen) => {
31 for (const neighbor of graph[source]) {

Callers 2

findRedundantConnectionFunction · 0.85
dfsFunction · 0.85

Calls 2

dfsFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected