Skip to content

Latest commit

 

History

History
executable file
·
10 lines (6 loc) · 602 Bytes

File metadata and controls

executable file
·
10 lines (6 loc) · 602 Bytes

124.Binary Tree Maximum Path Sum

Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

It remind me of LCA. It seems a compression and dp problem in high school.

It do not know how to know, even violent.

STD use dfs and backtracking. we use dfs and reach the end, then go back to the father. Then the father has choice, left or right or nothing (less than zero).