← 返回 doordash 的题目列表Maximum Tree Path Sum
类型:online_judge
Given a binary tree, find the path with the maximum path sum. The path must contain at least one node and does not necessarily need to go through the root.
Input Format
The tree's nodes are represented by integers, including both positive and negative numbers.
Output Format
Return the maximum path sum.
Test Cases
Input: [-10,9,20,null,null,15,7] Output: 42
Input: [-3] Output: -3
Input: [1,2,3] Output: 6
Input: [2,-1] Output: 2
Input: [5,-6,-7] Output: 5
Example
Input
-10,9,20,null,null,15,7