You are given an undirected graph that started as a tree with one extra edge added. Your task is to return the redundant edge whose removal makes the graph a tree again.
The redundant edge is the edge that creates a cycle in the graph.
Return the edge whose removal restores the tree structure.
Input: edges = [[1,2],[1,3],[2,3]]
Output: [2,3]
Explanation: Removing edge [2,3] restores the tree.
Input: edges = [[1,2],[2,3],[3,4],[1,4],[1,5]]
Output: [1,4]
Explanation: Removing edge [1,4] removes the cycle.
Input: edges = [[1,2],[2,3],[3,1]]
Output: [3,1]
Explanation: The last edge completes the cycle.
Sign in to write, run, and submit your solution against the full test suite.