Minimum Height Trees
Medium · Graphs · about 25 minutes
Asked at Google, Amazon, Microsoft, Meta.
A tree has n nodes 0..n-1 and n - 1 undirected edges. Choosing any node as the root gives a rooted tree with some height. Return every root that gives the minimum height, in any order.