#1466 - Reorder Routes to Make All Paths Lead to the City Zero
There are n cities numbered 0 to n - 1 and n - 1 directed roads forming a tree. Reorder the minimum number of roads so that every city can reach city 0. Return the minimum number of edges that need to be reversed.
| Input | Output |
|---|---|
n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]] | 3 |
n = 5, connections = [[1,0],[1,2],[3,2],[3,4]] | 2 |
n = 3, connections = [[1,0],[2,0]] | 0 |