Geeksforgeeks

Error

Given an undirected Connected graph of V vertices and E edges.

A critical connection is an edge that, if removed, will make some nodes unable to reach some other nodes. Find all critical connections in the graph.

**Note: **There are many possible orders for the answer. You are supposed to print the edges in sorted order, and also an edge should be in sorted order too. So if there's an edge between node 1 and 2, you should print it like (1,2) and not (2,1).

**Example 1:**

Input:Output:0 1 0 2Explanation: Both the edges in the graph are Crtical connections.

**Example 2:**

Input:Output:2 3Explanation: The edge between nodes 2 and 3 is the only Critical connection in the given graph.

**Your task:**

You don’t need to read input or print anything. Your task is to complete the function **criticalConnections()** which takes the integer V denoting the number of vertices and an adjacency list adj as input parameters and returns a list of lists containing the Critical connections in the sorted order.

**Expected Time Complexity: **O(V + E)

**Expected Auxiliary Space: **O(V)

**Constraints:**

1 ≤ V, E ≤ 10^{4}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Critical Connections

...