Start with all degree- nodes (leaves) in a queue. Remove them, decrement neighbors' degrees, add new leaves to queue. Repeat until nodes remain. These are the minimum height tree roots. Why ? The centroid of a tree is either one node or an edge. If it's an edge, both endpoints are valid roots. Time: . Each node is added to the queue exactly once. Space: for the degree array and queue.
Time complexity: .
Space complexity: .