Make graph strongly connected
Your task
Given a directed graph on n nodes (0..n-1) with a list of directed edges, return the minimum number of directed edges you must add so that the whole graph becomes strongly connected (every node reachable from every other). If it is already strongly connected, return 0. Constraints: 1 <= n <= 2000; edges may contain self-loops or duplicates.
Examples
min_edges_to_strongly_connect(n: int, edges: list[list[int]]) -> intExample 1
Input
min_edges_to_strongly_connect(5, [[0, 1], [1, 2], [2, 0], [2, 3], [3, 4]])Output
1