124. Binary Tree Maximum Path Sum
Practice Binary Tree Maximum Path Sum for free on NudgeCode: Hard, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
A path is a sequence of nodes where each pair of neighbours is connected by an edge, and no node appears twice. The path does not have to go through the root, and it contains at least one node. Return the largest possible sum of node values along any path.
Example
root = [-10,9,20,null,null,15,7] -> 42 (15 -> 20 -> 7)
Constraints
- 1 <= number of nodes <= 3 * 10^4
- -1000 <= Node.val <= 1000