Critical Connections in a Network - Problem
There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between servers ai and bi.
Any server can reach other servers directly or indirectly through the network.
A critical connection is a connection that, if removed, will make some servers unable to reach some other server.
Return all critical connections in the network in any order.
Input & Output
Example 1 — Simple Network
$
Input:
n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
›
Output:
[[1,3]]
💡 Note:
Servers 0, 1, 2 form a cycle, so any connection between them can be removed without disconnecting. However, connection [1,3] is critical - removing it would isolate server 3.
Example 2 — Linear Chain
$
Input:
n = 3, connections = [[0,1],[1,2]]
›
Output:
[[0,1],[1,2]]
💡 Note:
This is a linear chain where both connections are critical. Removing either [0,1] or [1,2] would disconnect the network into separate components.
Example 3 — Single Connection
$
Input:
n = 2, connections = [[0,1]]
›
Output:
[[0,1]]
💡 Note:
With only two servers and one connection, that connection is critical since removing it would completely disconnect the servers.
Constraints
- 1 ≤ n ≤ 105
- n - 1 ≤ connections.length ≤ 105
- 0 ≤ ai, bi ≤ n - 1
- ai ≠ bi
- There are no repeated connections.
Visualization
Tap to expand
Understanding the Visualization
1
Input Network
Servers connected by bidirectional links
2
Identify Bridges
Find connections critical for connectivity
3
Output Result
Return all critical connections
Key Takeaway
🎯 Key Insight: Critical connections are graph bridges - edges whose removal disconnects the network into separate components
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code