Maximum Difference Between Node and Ancestor

Medium · Trees · about 15 minutes

Asked at Amazon, Google, Meta, Microsoft.

Return the maximum |a.val - b.val| over pairs of different nodes where a is an ancestor of b.

Related guides