Extra cable in the network
A network of n computers labelled 1 to n was wired as a tree (connected, no loops) until someone plugged in one extra cable. edges lists every cable as [a, b] in the order it was installed. Return the cable whose removal turns the network back into a tree; if several would work, return the one that appears last in edges, written exactly as it appears there.
The extra cable may duplicate an existing one. Aim for near-linear time.
Examples
extra_cable(3, [[1,2],[1,3],[2,3]])→[2,3]extra_cable(5, [[1,2],[2,3],[3,4],[1,4],[1,5]])→[1,4]extra_cable(5, [[1,2],[2,3],[3,1],[3,4],[4,5]])→[3,1]