Problem 865 · Medium

Smallest Subtree with all the Deepest Nodes

One post-order pass returns each subtree depth and its deepest-common-ancestor candidate.

Open the interactive visualisation