A tree is a set of points joined by links so that every point can be reached from every other point, and there is no loop.
You are given a graph that began as a tree with n points, numbered 1 to n. Then one extra link was added between two different points that were not already linked. The list edges holds all n links. An entry edges[i] = [a_i, b_i] is a link between points a_i and b_i.
Return one link you can remove so that the graph is a tree again. If several links work, return the one that appears last in edges.
Examples
Example 1:
Input: edges = [[1,2],[2,3],[1,3]]
Output: [1,3]
Explanation: All three links are in the loop. Removing any one fixes it, and [1,3] is the last one in the list.
Example 2:
Input: edges = [[1,2],[1,3],[3,4],[2,4],[4,5]]
Output: [2,4]
Explanation: The loop is 1-2-4-3-1. Of its links, [2,4] comes last in the list.
Example 3:
Input: edges = [[1,4],[3,4],[1,3],[1,2],[4,5]]
Output: [1,3]
Explanation: The loop is made by [1,4], [3,4] and [1,3]. The last of them in the list is [1,3].