Very Short, Clean, and Simple Solution
IntuitionWe simply remove all the leaves from the graph one by one. And when only a cycle remains we take the last element.Code
# Intuition
We simply remove all the leaves from the graph one by one. And when only a cycle remains we take the last element.

# Code
```javascript []

const findRedundantConnection = (edges) => {
    const leaves = edges.flat().filter((v, i, a) => a.indexOf(v) === a.lastIndexOf(v));
    if (leaves.length) {
        return findRedundantConnection(edges.filter(([a, b]) => !leaves.includes(a) && !leaves.includes(b)));
    }
    return edges.at(-1);
};
```
['JavaScript']