1. 程式人生 > >演算法分析與設計丨第十八週丨LeetCode(21)——Binary Tree Maximum Path Sum(Hard)

演算法分析與設計丨第十八週丨LeetCode(21)——Binary Tree Maximum Path Sum(Hard)

題目描述:

Given a 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 containat least one node and does not need to go through the root.

For example:
Given the below binary tree,

       1
      / \
     2   3

Return 6.