(edges)
| 5 | * @return {number[]} |
| 6 | */ |
| 7 | var findRedundantConnection = function (edges) { |
| 8 | const graph = new Array(1000 + 1).fill().map(() => []); |
| 9 | |
| 10 | for (const [src, dst] of edges) { |
| 11 | const hasNodes = src in graph && dst in graph; |
| 12 | if (hasNodes && hasRedundantConnection(graph, src, dst)) |
| 13 | return [src, dst]; |
| 14 | |
| 15 | graph[src].push(dst); |
| 16 | graph[dst].push(src); |
| 17 | } |
| 18 | }; |
| 19 | |
| 20 | const hasRedundantConnection = (graph, source, target, seen = new Set()) => { |
| 21 | if (seen.has(source)) return false; |
nothing calls this directly
no test coverage detected