Back to DSA

Critical Connections in a Network

hard
Acceptance: 44%
GraphsDFS

A network of n nodes is connected by undirected edges. A bridge is an edge whose removal would disconnect the graph. Identify all bridges in the given network.

Examples

Example 1:
Input:n = 5, connections = [[0,1],[1,2],[2,0],[1,3],[3,4]]
Output:[[1,3],[3,4]]
Explanation: Removing either edge [1,3] or [3,4] disconnects node 3 or 4 from the rest. The edges in the cycle 0-1-2 are not bridges.

Hints

00:00
1234567