Strongly Connected Components Count
Strongly Connected Components Count
Given a directed graph with n nodes (0-indexed) and edges [u, v], return how many strongly connected components (SCCs) it has.
Function signature
func SCCCount(n int, edges [][]int) int
Example
n = 5
edges = [[0,1],[1,2],[2,0],[1,3],[3,4],[4,3]]
output = 2
Constraints
- 0 <= n <= 200_000
- 0 <= len(edges) <= 200_000
- 0 <= u, v < n
Notes
- Kosaraju or Tarjan both work in O(n + m).
Run tests to see results
No issues detected