solve(edges) — a tree with nodes 1..n had one extra edge added, producing
the n edges you receive (each [a, b] is undirected). Return the edge that can
be removed so the result is a tree again. If several edges qualify, return the one
that appears last in the input.
Process the edges in order with Union–Find: the first edge whose endpoints are
already connected is the one that closes the cycle — and it is the last cycle edge
in input order.
Examples
solve([[1,2],[1,3],[2,3]]) → [2,3]
solve([[1,2],[2,3],[3,4],[1,4],[1,5]]) → [1,4]
solve([[1,4],[3,4],[1,3],[1,2],[4,5]]) → [1,3]Sample tests