Problem 1026 · Medium

Maximum Difference Between Node and Ancestor

Carry the smallest and largest ancestor values down the tree; each node is compared with those two extremes.

Open the interactive visualisation