← ALL NOTES
Dynamic Programming

124. Binary Tree Maximum Path Sum

Post-order DFS carrying two different quantities. At each node, the best path that bends through it is node->val + max(0, leftGain) + max(0, rightGain) — clamping each child's contribution to 0 means…

Loading…