Problem
A tree with n nodes labelled 1 to n had one extra edge added, so edges now has n undirected edges and exactly one cycle. Return an edge you can remove to turn the graph back into a tree. If several edges would work, 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]
Constraints
3 <= n <= 1000edges.length == n1 <= a < b <= n for every edge [a, b], and there are no repeated edgesThe graph is connected