Redundant Connection

Medium

📝 Description

Find an edge that can be removed to make a tree (detect cycle in undirected graph).

Input Format

[[u1,v1], [u2,v2], ...] (edges of a graph)

Output Format

[u, v] (edge to remove)

Constraints

3 ≤ n ≤ 1000

🔍 Sample Input

[[1,2],[1,3],[2,3]]
            

✅ Sample Output

[2,3]
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run