Problem Description
Given a binary tree T, find the maximum path sum.
The path may start and end at any node in the tree.
1 <= Number of Nodes <= 7e4
-1000 <= Value of Node in T <= 1000
The first and the only argument contains a pointer to the root of T, A.
Return an integer representing the maximum sum path.
Input 1:
1 / \ 2 3
Input 2:
20 / \ -10 20 / \ -10 -50
Output 1:
6
Output 2:
40
Explanation 1:
The path with maximum sum is: 2 -> 1 -> 3
Explanation 2:
The path with maximum sum is: 20 -> 20
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.