63. Redundant Connection

A tree with nodes 1..n had one extra edge added. Return the edge that can be removed so the graph becomes a tree again. If several qualify, return the one that appears last in edges.

Example 1

Input: edges = [[1,2],[1,3],[2,3]]
Output: [2,3]

Example 2

Input: edges = [[1,2],[2,3],[3,4],[1,4],[1,5]]
Output: [1,4]
Hint 1

Add edges one by one. The first edge whose endpoints are already connected closes a cycle.

Union FindGraph