> For the complete documentation index, see [llms.txt](https://llssff.gitbook.io/coding-problems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://llssff.gitbook.io/coding-problems/tree-traversal/max-path-sum-from-leaf-to-root.md).

# Max Path Sum From Leaf To Root

Given a binary tree in which each node contains an integer number. Find the maximum possible path sum from a leaf to root.

Assumptions

The root of given binary tree is not null.

Examples

&#x20;        10

&#x20;      /      \\

&#x20;   -2        7

&#x20; /     \\

8      -4

The maximum path sum is 10 + 7 = 17.

**Solution:** Recursive bottom up

Base Case: root == null, return 0

From Children: get two max value paths

At current level:&#x20;

To parent: pick higher value path between left and right and return to parent
