Binary Tree Maximum Path Sum
Hard
Trees
DFS
Recursion
Find max path sum in binary tree (any node to any node).
Input: level-order tree
Output: max path sum
Constraints
See problem-specific constraints. Optimized solution required.
Examples
Example 1:
Input: -10 9 20 null null 15 7
Output:
Example 2:
Input: -10 9 20 null null 15 7
Output:
Hints
Consider a dfs approach.
Think about time complexity.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console