Problem 2538 · Hard

Difference Between Maximum and Minimum Price Sum

Try each node as the root, find the heaviest and lightest root-to-node price sums, and keep the largest gap between them.

Open the interactive visualisation