Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Home
Talentd Logo
Talentd

Your trusted platform to ace any job interviews, craft the perfect resumes, and land your dream jobs.

P
Featured on
Product Hunt
â–²455
All services are online

Products

  • Resume Review
  • Company Prep Pack
  • DSA Corner
  • Jobs
  • Internships
  • Fresher Jobs
  • Roadmaps
  • Tax Calculator

Resources

  • Articles
  • DRDO Internships

Support

  • Contact Us

DSA & Interview Prep

  • DSA Questions
  • DSA Sheets
  • Company Questions
  • Topics

Company

  • Companies Hiring
  • About
  • Contact
  • Advertisement

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Delivery Policy

Popular Skills

Browse All Skills →

Popular Tags

Browse All Tags →

© 2025 Talentd.in - All rights reserved

Privacy PolicyTerms & Conditions
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
DSA Corner
DashboardQuestionsTopicsCompaniesSheets

Talentd Logo
Talentd

Your trusted platform to ace any job interviews, craft the perfect resumes, and land your dream jobs.

P
Featured on
Product Hunt
â–²455
All services are online

Products

  • Resume Review
  • Company Prep Pack
  • DSA Corner
  • Jobs
  • Internships
  • Fresher Jobs
  • Roadmaps
  • Tax Calculator

Resources

  • Articles
  • DRDO Internships

Support

  • Contact Us

DSA & Interview Prep

  • DSA Questions
  • DSA Sheets
  • Company Questions
  • Topics

Company

  • Companies Hiring
  • About
  • Contact
  • Advertisement

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Delivery Policy

Popular Skills

Browse All Skills →

Popular Tags

Browse All Tags →

© 2025 Talentd.in - All rights reserved

Privacy PolicyTerms & Conditions
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
DSA Corner
DashboardQuestionsTopicsCompaniesSheets
Talentd Logo
Talentd

Your trusted platform to ace any job interviews, craft the perfect resumes, and land your dream jobs.

P
Featured on
Product Hunt
â–²455
All services are online

Products

  • Resume Review
  • Company Prep Pack
  • DSA Corner
  • Jobs
  • Internships
  • Fresher Jobs
  • Roadmaps
  • Tax Calculator

Resources

  • Articles
  • DRDO Internships

Support

  • Contact Us

DSA & Interview Prep

  • DSA Questions
  • DSA Sheets
  • Company Questions
  • Topics

Company

  • Companies Hiring
  • About
  • Contact
  • Advertisement

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Delivery Policy

Popular Skills

Browse All Skills →

Popular Tags

Browse All Tags →

© 2025 Talentd.in - All rights reserved

Privacy PolicyTerms & Conditions
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
DSA Corner
DashboardQuestionsTopicsCompaniesSheets
Talentd Logo
Talentd

Your trusted platform to ace any job interviews, craft the perfect resumes, and land your dream jobs.

P
Featured on
Product Hunt
â–²455
All services are online

Products

  • Resume Review
  • Company Prep Pack
  • DSA Corner
  • Jobs
  • Internships
  • Fresher Jobs
  • Roadmaps
  • Tax Calculator

Resources

  • Articles
  • DRDO Internships

Support

  • Contact Us

DSA & Interview Prep

  • DSA Questions
  • DSA Sheets
  • Company Questions
  • Topics

Company

  • Companies Hiring
  • About
  • Contact
  • Advertisement

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Delivery Policy

Popular Skills

Browse All Skills →

Popular Tags

Browse All Tags →

© 2025 Talentd.in - All rights reserved

Privacy PolicyTerms & Conditions
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
Jobs
Learning
Career Tools
Talentd Logo
Talentd#1 Freshers Platform
DSA Corner
DashboardQuestionsTopicsCompaniesSheets
Back to Problems

1192. Critical Connections in a Network

Hard56.9% Acceptance
Depth-First SearchGraphBiconnected Component
Asked by:
Bloomberg
ProblemHints (1)Solutions (7)VideosCompanies (5)Notes

Problem Statement

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.

Example 1:

Input: n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
Output: [[1,3]]
Explanation: [[3,1]] is also accepted.

Example 2:

Input: n = 2, connections = [[0,1]]
Output: [[0,1]]

Constraints:

  • 2 <= n <= 105
  • n - 1 <= connections.length <= 105
  • 0 <= ai, bi <= n - 1
  • ai != bi
  • There are no repeated connections.
Talentd Logo
Talentd

Your trusted platform to ace any job interviews, craft the perfect resumes, and land your dream jobs.

P
Featured on
Product Hunt
â–²455
All services are online

Products

  • Resume Review
  • Company Prep Pack
  • DSA Corner
  • Jobs
  • Internships
  • Fresher Jobs
  • Roadmaps
  • Tax Calculator

Resources

  • Articles
  • DRDO Internships

Support

  • Contact Us

DSA & Interview Prep

  • DSA Questions
  • DSA Sheets
  • Company Questions
  • Topics

Company

  • Companies Hiring
  • About
  • Contact
  • Advertisement

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Delivery Policy

Popular Skills

Browse All Skills →

Popular Tags

Browse All Tags →

© 2025 Talentd.in - All rights reserved

Privacy PolicyTerms & Conditions
B
A
Amazon
M
Microsoft
A
Adobe
F
Facebook

Approach

The key idea behind #1192 Critical Connections in a Network is to identify bridges in an undirected graph. A bridge is an edge whose removal increases the number of connected components in the network. In graph theory, this can be efficiently solved using a Depth-First Search (DFS) based algorithm commonly known as Tarjan’s Algorithm.

During DFS traversal, we assign each node a discovery time and track the earliest reachable discovery time using a low[] array. If a neighbor cannot reach an ancestor of the current node through a back edge, the edge connecting them is considered a critical connection. The algorithm keeps updating discovery and low-link values while exploring neighbors.

By using adjacency lists and a single DFS traversal, all bridges can be detected efficiently. This approach is optimal because each node and edge is processed once, making it well-suited for large network graphs commonly seen in coding interviews.

Complexity

ApproachTime ComplexitySpace Complexity
DFS with Tarjan's Bridge AlgorithmO(V + E)O(V + E)

Video Solution Available

take U forward

View all video solutions

Problem Hints

Use these hints if you're stuck. Try solving on your own first.

1
Hint 1

Use Tarjan's algorithm.

Ready to see the solutions?View Solutions

Solutions (7)

Depth-First Search (DFS) and Tarjan's Algorithm

This approach leverages Tarjan's Algorithm to find bridges in an undirected graph. A bridge, also known as a critical connection, is an edge which, when removed, increases the number of connected components in a graph.

The main idea is to use a DFS traversal while keeping track of two things for each node:

  • Discovery time: The time when a node is first visited.
  • Lowest point: The smallest discovery time reachable from the node, including itself or its descendants.

During the DFS traversal, if a node discovers a node that was discovered earlier, we update the current node's lowest point based on the discovered node unless it is a direct parent of the current node which means it's a backtracking edge. If the lowest point of the descendant is greater than the discovery time of the current node, then the connection between them is a critical connection.

The time complexity is O(V + E) where V is the number of vertices and E is the number of edges. The space complexity is also O(V + E) due to the graph representation and recursion stack.

PythonC++JavaJavaScriptC#
1def criticalConnections(n, connections):
2    from collections import defaultdict
3    graph = defaultdict(list)
4    for u, v in






Explanation

The code defines a function criticalConnections which constructs a graph from the given connections. It uses DFS traversal to calculate the disc and low values. The critical connections are collected in critical_edges list.

Union-Find with Path Compression

The Union-Find approach is less direct for this problem as it better suits static connectivity queries, but it can verify the disconnection effect of removing an edge by checking connectivity before and after its removal.

Here, a variation of Kruskal's algorithm can be employed with additional tracking to retry connections and verify their critical status. However, this requires additional complexity and is not the standard usage for critical connections.

So, while possible, using Union-Find isn't recommended due to its inefficiency in recomputing components with high time complexity.

The time complexity on worst-case is O(E^2) due to the need for reconstructing the Union-Find structure. The space complexity is O(V) for the Union-Find structure.

PythonC++
1class UnionFind:
2






Video Solutions

Watch expert explanations and walkthroughs

G-55. Bridges in Graph - Using Tarjan's Algorithm of time in and low time

take U forward
23:25187,901 views

Asked By Companies

5 companies
B
Bloomberg
A
Amazon
M
Microsoft
A
Adobe
F
Facebook

Prepare for Interviews

Practice problems asked by these companies to ace your technical interviews.

Explore More Problems

Notes

Personal Notes

Jot down your thoughts, approach, and key learnings

0 characters

Similar Problems

Clone GraphMedium
Course ScheduleMedium
Course Schedule IIMedium
Graph Valid TreeMedium
More similar problems

Related Topics

Depth-First SearchGraphBiconnected Component

Problem Stats

Acceptance Rate56.9%
DifficultyHard
Companies5

Practice on LeetCode

Solve with full IDE support and test cases

Solve Now

Frequently Asked Questions

Is Critical Connections in a Network asked in FAANG interviews?

Yes, bridge detection and Tarjan's Algorithm are common graph interview topics at FAANG-level companies. Problems like this test a candidate's understanding of DFS, graph traversal, and advanced graph concepts such as biconnected components.

What is the optimal approach for Critical Connections in a Network?

The optimal approach uses Tarjan's Algorithm with Depth-First Search to detect bridges in a graph. By tracking discovery times and low-link values, the algorithm determines whether an edge is critical. This allows all bridges to be found in linear time.

Why are low-link values important in Critical Connections problems?

Low-link values represent the earliest discovery time reachable from a node through DFS, including back edges. They help determine whether a subtree can reconnect to an ancestor, which is essential for identifying bridges.

What data structure is best for solving Critical Connections in a Network?

An adjacency list is the most efficient data structure for representing the graph in this problem. It allows fast traversal of neighbors during DFS and keeps memory usage efficient for sparse graphs.

connections
:
5
graph
[
u
]
.
append
(
v
)
6
graph
[
v
]
.
append
(
u
)
7
8
low
=
[
-
1
]
*
n
9
disc
=
[
-
1
]
*
n
10
parent
=
[
-
1
]
*
n
11
critical_edges
=
[
]
12
time
=
0
13
14
def
dfs
(
u
)
:
15
nonlocal
time
16
disc
[
u
]
=
low
[
u
]
=
time
17
time
+=
1
18
19
for
v
in
graph
[
u
]
:
20
if
disc
[
v
]
==
-
1
:
21
parent
[
v
]
=
u
22
dfs
(
v
)
23
24
low
[
u
]
=
min
(
low
[
u
]
,
low
[
v
]
)
25
26
if
low
[
v
]
>
disc
[
u
]
:
27
critical_edges
.
append
(
[
u
,
v
]
)
28
elif
v
!=
parent
[
u
]
:
29
low
[
u
]
=
min
(
low
[
u
]
,
disc
[
v
]
)
30
31
for
i
in
range
(
n
)
:
32
if
disc
[
i
]
==
-
1
:
33
dfs
(
i
)
34
35
return
critical_edges
def
__init__
(
self
,
size
)
:
3
self
.
root
=
list
(
range
(
size
)
)
4
5
def
find
(
self
,
x
)
:
6
if
self
.
root
[
x
]
==
x
:
7
return
x
8
self
.
root
[
x
]
=
self
.
find
(
self
.
root
[
x
]
)
9
return
self
.
root
[
x
]
10
11
def
union
(
self
,
x
,
y
)
:
12
rootX
=
self
.
find
(
x
)
13
rootY
=
self
.
find
(
y
)
14
if
rootX
!=
rootY
:
15
self
.
root
[
rootY
]
=
rootX
16
return
True
17
return
False
18
19
def
connected
(
self
,
x
,
y
)
:
20
return
self
.
find
(
x
)
==
self
.
find
(
y
)
21
22
def
criticalConnections
(
n
,
connections
)
:
23
result
=
[
]
24
for
i
in
range
(
len
(
connections
)
)
:
25
modified
=
connections
[
:
i
]
+
connections
[
i
+
1
:
]
26
uf
=
UnionFind
(
n
)
27
28
for
u
,
v
in
modified
:
29
uf
.
union
(
u
,
v
)
30
31
if
not
uf
.
connected
(
connections
[
i
]
[
0
]
,
connections
[
i
]
[
1
]
)
:
32
result
.
append
(
connections
[
i
]
)
33
34
return
result

Explanation

The code implements a brute-force check of each edge's removal effect by rebuilding a Union-Find structure for each remaining connection set. It provides an intuitive understanding though not efficient for large inputs.