Search
⌘K

Leetcode 2538. Difference Between Maximum and Minimum Price Sum

Given a tree with node prices, choose a root to maximize the difference between the largest and smallest root-to-node path price sums; compute this maximum over all possible roots. The core challenge is computing per-node max/min root-to-node sums efficiently (use tree DP with rerooting to get both extremes in O(n)).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.