LeetCode "Binary Tree Maximum Path Sum"

http://yucoding.blogspot.com/2012/12/leetcode-question-13-binary-tree.html

Usually for tree problems, it is either recursion or traversal. For this one, it is obviously by recursion, but.. it utilizes recursion in a highly flexible manner. It is not an easy one.

1. When dfs method return, it returns the path with larger sum - only one path: could be root + left, and root + right

2. When checking current max sum path, left ight oot should be involved all, because such a path could be anything.

原文地址:https://www.cnblogs.com/tonix/p/3913863.html