DiffPush Tier Binary Trees · Medium Problems O(n) · O(h)
A courier drone flies a binary-tree network of pickup towers, each carrying a parcel value that can be negative (a disposal fee). A route may start at any tower, follow connected links, and stop at any tower — but never revisits one. The dispatcher wants the maximum total value achievable, knowing sometimes the best route is a single tower and negative branches should be abandoned mid-flight.
Input: The root of a binary tree given as a level-order array where null marks a missing child. Values may be negative.
Output: Return an integer: the maximum sum of node values over any non-empty path in the tree.
1 <= number of nodes <= 10^5-1000 <= node value <= 1000Input: {"tree":[1,2,3]}
Output: 6
The bend 2 -> 1 -> 3 collects all three positive towers.
Input: {"tree":[-10,9,20,null,null,15,7]}
Output: 42
Skip the negative root; the path 15 -> 20 -> 7 sums to 42.