Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Latest commit

 

History

History
22 lines (14 loc) · 716 Bytes

Max_Path_Sum_In_Binary_Tree.md

File metadata and controls

22 lines (14 loc) · 716 Bytes

Max Path Sum In Binary Tree

Problem Statement

Write a function that takes in a Binary Tree and returns its max path sum. A path is a collection of connected nodes where no node is connected to more than two other nodes; a path sum is the sum of the values of the nodes in a particular path. Each Binary Tree node has a value stored in a property called "value" and two children nodes stored in properties called "left" and "right," respectively. Children nodes can either be Binary Tree nodes themselves or the None (null) value.

Sample input: 1 / \ 2 3 / \ / \ 4 5 6 7 Sample output: 18

Solution

Check this Python code.