← 返回 bytedance 的题目列表Binary Tree Maximum Path Sum
类型:online_judge
Given a non-empty binary tree, find the maximum path sum. The path must contain at least one node and does not need to go through the root.
Input:
A binary tree with integer node values.
Output:
An integer indicating the maximum path sum.
Example 1:
Input: [1, 2, 3]
Output: 6
Example 2:
Input: [-10, 9, 20, null, null, 15, 7]
Output: 42
Constraints:
The number of nodes in the tree is in the range [1, 1000].
-1000 <= Node.val <= 1000
Example
Input
1 2 3