Critical Connections (Bridges) Problem

Critical Connections (Bridges) Problem — ExecCode Hard DSA Practice

Solve the Critical Connections (Bridges) problem on ExecCode. Free online hard DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

There are n servers numbered 0 to n-1 connected by undirected connections[i] = [a,b]. A critical connection is a connection whose removal disconnects the graph (a bridge). Return all critical connections in any order.

Examples

Input n = 6, connections = [[0, 1], [1, 2], [2, 0], [1, 3], [3, 4], [4, 5], [5, 3]]; Output [[1, 3]]. Input n = 2, connections = [[0, 1]]; Output [[0, 1]]

Constraints

2 ≤ n ≤ 10^5 n-1 ≤ connections.length ≤ 10^5 Graph is connected

Practice Critical Connections (Bridges) free on ExecCode. Browse DSA problems, topic map, and placement guides.