Imagine you're a network administrator managing a critical server infrastructure where n servers (numbered 0 to n-1) are connected by bidirectional links. Your network is represented by connections[i] = [a_i, b_i], meaning servers a_i and b_i can communicate directly.
Currently, every server can reach every other server either directly or through intermediate servers. However, some connections are more critical than others!
A critical connection (bridge) is a link that, if removed, would split the network into disconnected parts, making some servers unreachable from others.
Your mission: Find all critical connections that keep the network fully connected. Without these bridges, your network would fragment!
Example: If servers 0-1-2 form a line, then both connections [0,1] and [1,2] are critical because removing either would disconnect the network.
Input & Output
Visualization
Time & Space Complexity
For each of E edges, we perform a DFS/BFS taking O(V + E) time
Space for adjacency list representation and recursion stack
Constraints
- 2 โค n โค 105
- n - 1 โค connections.length โค 105
- 0 โค ai, bi โค n - 1
- ai โ bi
- There are no repeated connections
- The given graph is connected