less than 1 minute read

Given a binary tree root, return the largest sum of any path between any two nodes.

Constraints

  • n ≤ 100,000 where n is the number of nodes in root

https://binarysearch.com/problems/Largest-Tree-Sum-Path

Examples

Example 1

Input

  • root =

Output

  • answer = 31

Explanation

The largest sum path is: [8, 7, 4, 12]

Solution

Leave a comment