← 返回 doordash 的题目列表Binary Tree Maximum Path Sum with Modified Return
类型:online_judge
doordash
Given a binary tree, find the maximum path sum and return the corresponding path. The path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections (the path does not necessarily need to pass through the root).
Example
Example 1:
Input: [1,2,3] Output: 6 Path: [2, 1, 3]
Example 2:
Input: [-10,9,20,null,null,15,7] Output: 42 Path: [15, 20, 7]
Constraints
The number of nodes in the tree is in the range [1, 3 * 10^4]
-1000 <= Node.val <= 1000
Example
Input
[1,2,3]