Back to the 100
Problem 090Graphs
Medium

Redundant Connection

090

Given edges of an undirected graph that started as a tree plus one extra edge, return the edge that creates a cycle.

EXAMPLES

Example 1
Input
{
  "edges": [
    [
      1,
      2
    ],
    [
      1,
      3
    ],
    [
      2,
      3
    ]
  ]
}

Output
[
  2,
  3
]

FUNCTION SHAPE

edges: intMatrixintArray
00:00
2 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.