findRedundantConnection = function (edges) {
    const graph = new Array((1000 + 1)).fill().map(() => []);

    for (const [ src, dst ] of edges) {
        const hasNodes = (src in graph) && (dst in graph)
        if (hasNodes && hasRedundantConnection(graph, src, dst)) return [ src, dst ];

        graph[src].push(dst);
        graph[dst].push(src);
    }
}
https://leetcode.com/problems/redundant-connection/
Time O((V)^2 + E) | Space O(V + E)
@param {number[][]} edges
@return {number[]}