Algorithm · Uber · Hard
You are given a directed tree containing n nodes numbered from 1 through n. It has n - 1 directed edges, with the ith edge directed from from[i] to to[i]. You can select any node to serve as the root. Once the root is selected, you may reverse edges as needed so that every edge is directed outward from the root. Determine the smallest number of reversals possible across all choices of the root. Constraints: 1 ≤ n ≤ $$10^5$$ 1 ≤ from[i], to[i] ≤ n There is at most one edge…
Checking your access…