Search
⌘K

Leetcode 2858. Minimum Edge Reversals So Every Node Is Reachable

Given a directed graph whose underlying undirected graph is a tree, compute for every node the minimum number of edge reversals required so that starting from that node you can reach all other nodes. This reduces to a tree shortest-path / rerooting problem by treating each original edge as cost 0 in its given direction and cost 1 if reversed, solvable with a 0-1 BFS or tree DP + rerooting to obtain answers for all nodes.

Asked at:

Microsoft

Microsoft


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late January, 2026

Microsoft

Microsoft

Senior

Other than some flavor text, the question was exactly as listed in the leetcode entry

Comments

Your account is free and you can post anonymously if you choose.