Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5578 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 714 |

@Manikanta punnam | 579 |

@sriramgoparaju99 | 532 |

@yashkaril4 | 517 |

@praveenbgp6 | 517 |

@prankursharma31 | 489 |

@rdakka | 465 |

@sonamnigam1999 | 441 |

@purohitmn02 | 427 |

@sonamkumari63928 | 426 |

@ShubhankarPandey | 419 |

Complete Leaderboard |

Given a Directed Graph with V vertices and E edges, Find the number of strongly connected components in the graph.

**Example 1:**

Input:Output:3Explanation: We can clearly see that there are 3 Strongly Connected Components in the Graph

**Example 2:**

Input:Output:1Explanation: All of the nodes are connected to each other. So, there's only one SCC.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **kosaraju()** which takes the number of vertices V and adjacency list of the graph as inputs and returns an integer denoting the number of strongly connected components in the given graph.

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

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

**Constraints:**

1 ≤ V ≤ 5000

0 ≤ E ≤ (V*(V-1))

0 ≤ u, v ≤ N-1

Sum of E over all testcases will not exceed 25*10^{6}

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?

Yes
Strongly Connected Components (Kosaraju's Algo)

...