A tree with n nodes (labeled 1…n) had exactly one extra undirected edge added. Given the resulting edge list, return the edge that can be removed to restore a tree. If several qualify, return the one appearing last in the input.
Input
n n (the graph has exactly n edges)u vOutput: the edge u v.
3 3 1 2 1 3 2 3
2 3
5 5 1 2 2 3 3 4 1 4 1 5
1 4
Run your code against the sample tests, or Submit to run the full suite.