#1192

Critical Connections in a Network

Hard Tarjan's bridges

  1. Read
  2. Understand
  3. Hints
  4. Approach
  5. Solution
  6. Solved

?The problem

In an undirected connected network, return every connection whose removal disconnects some servers (the bridges).

This is a short summary in our own words. Read the full statement and examples on LeetCode: open problem ↗

◎Understanding

Really asking: edges whose removal cuts the network.

Why this works: Tarjan: low[v] is the earliest node v's subtree can reach with a back edge. If low[v] > disc[u], the edge u-v is the only way back.

Example: 0-1, 1-2, 2-0, 1-3

triangle 0-1-2 has back edges1-3: low[3] = 3 > disc[1] → bridge [1,3]

✦Hints open one at a time

↗Approach

</>Solution (Java)

!Common mistake

Updating low through the parent edge, which hides every bridge.

Solve on LeetCode ↗
Complexity
  • Time: O(V + E).
  • Space: O(V + E).
Topic: Graphs
🎬 Episodes 74–85: video coming soon