LearnPy Hub
← Arena
AdvancedRating 1800

Best Path in a Binary Tree

A binary tree is given level by level with N for an empty spot. A path goes between any two nodes (or is a single node) without repeating nodes. Print the largest sum of values on a path.

Input

One line of values and N.

Output

One integer.

Sample 1

Input
1 2 3
Output
6

Sample 2

Input
-10 9 20 N N 15 7
Output
42
solution.py
Output appears here
Best Path in a Binary Tree · Python Arena problem · LearnPy Hub