Close
Topic list
Count Strongly Connected Components (Kosaraju’s Algorithm)
HARD
40 mins
Graph
Topics (Covered in this problem)
Problem solved
Skill meter
Graph
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Count Strongly Connected Components (Kosaraju’s Algorithm)

Contributed by
Vishal Modani
Hard
0/120
Avg time to solve 40 mins
Success Rate 65 %
Share

## Problem Statement

#### A directed graph is said to be strongly connected if every vertex is reachable from every other vertex. The strongly connected components of a graph are the subgraphs which are themselves strongly connected.

##### Note :
``````Use zero-based indexing for the vertices.

The given graph doesn’t contain any self-loops.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````1
5 6
0 1
1 2
1 4
2 3
3 2
4 0
``````
##### Sample Output 1 :
``````2
``````
##### Explanation of sample input 1 :
``````For the first test case, the graph is shown below. There are two SCCs in the graph, which are enclosed in the boxes as shown in the image below.
``````

##### Sample Input 2 :
``````2
1 0
4 4
0 1
1 2
2 3
3 1
``````
##### Sample Output 2 :
``````1
2
``````
Auto
Console