LeetCode 124 Binary Tree Maximum Path Sum - Problem Statement

The problem

Given a binary tree, find the maximum path sum. A path is a sequence of nodes connected by edges, and it doesn't have to pass through the root.

With this tree:

   1
  / \
 2   3

The max path is 2 → 1 → 3 with sum 6.

With this tree:

  -10
  /  \
 9   20
    /  \
   15   7

The max path is 15 → 20 → 7 with sum 42. The negative root is excluded.

Nodes can have negative values. A path can start and end at any node.

Constraints: 11 \le nodes 3×104\le 3 \times 10^4. Values from 1000-1000 to 10001000.