Medium Accuracy: 49.73% Submissions: 14544 Points: 4
Given a graph with N nodes and M directed edges. Your task is to complete the function kosaraju() which returns an integer denoting the number of strongly connected components in the graph.
The first line of input contains an integer T. Then T test cases follow. Each test case contains two integers N and M. In the next line there are M space-separated values u,v denoting an edge from u to v.
For each test case in a new line output will an integer denoting the no of strongly connected components present in the graph.
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(N + M). Expected Auxiliary Space: O(N).
1 <= T <= 100
1 <= N <= 5000
0 <= M <= (N*(N-1))
0 <= u, v <= N-1
Sum of M over all testcases will not exceed 25*106