Think of a path as a walk along the edges of a binary tree. You start at any node, move from a node to its parent or to one of its children, and never visit a node twice. The walk can start and end anywhere, and it does not have to include the root.
The sum of a path is the total of the values of the nodes on it. Return the largest sum that any path with at least one node can have.
How the judge passes the data
Examples
Example 1:
Input: root = [2,-1,3]
Output: 5
Explanation: The best path is 2 -> 3 with sum 5. Adding -1 would make it smaller.
Example 2:
Input: root = [-8,4,6,null,null,5,-3]
Output: 11
Explanation: The best path is 5 -> 6 with sum 11. It does not touch the root.
Example 3:
Input: root = [-4,-9,-2]
Output: -2
Explanation: All values are negative. The best path is the single node -2.