Problem 865 · Medium
One post-order pass returns each subtree depth and its deepest-common-ancestor candidate.
Open the interactive visualisation