Error
|
|
---|---|
@Ibrahim Nash | 6379 |
@blackshadows | 6329 |
@mb1973 | 5358 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@ritiksethi21 | 1050 |
@aroranayan999 | 807 |
@RizulBansal | 685 |
@ashishtrehan002 | 538 |
@hemantgarg923 | 528 |
@simrangoyal | 526 |
@ronaldo77 | 520 |
@anishrajan | 505 |
@thanosagain | 505 |
@ssparteek470 | 495 |
@rahul2312 | 491 |
Complete Leaderboard |
Given an undirected and connected graph of V vertices and E edges and another edge (c-d), the task is to find if the given edge is a bridge in graph, i.e., removing the edge disconnects the graph.
Example 1:
Input:c = 1, d = 2 Output: 1 Explanation: From the graph, we can clearly see that removing the edge 1-2 will result in disconnection of the graph. So, it is a bridge Edge and thus the Output 1.
Example 2:
Input:c = 0, d = 2 Output: 0 Explanation:
Removing the edge between nodes 0 and 2 won't affect the connectivity of the graph. So, it's not a Bridge Edge. All the Bridge Edges in the graph are marked with a blue line in the above image.
Your Task:
You don't need to read input or print anything. Your task is to complete the function isBridge() which takes number of vertices V, the number of edges E, an adjacency lsit adj and two integers c and d denoting the edge as input parameters and returns 1 if the given edge c-d is a Bridge. Else, it returns 0.
Expected Time Complexity: O(V + E).
Expected Auxiliary Space: O(V).
Constraints:
1 ≤ V,E ≤ 105
0 ≤ c, d ≤ V-1
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes