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.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.