Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.