L596 minimum Subtree
Given a binary tree, find the subtree with minimum sum. Return the root of the subtree.
Notice
LintCode will print the subtree which root is your return node. It's guaranteed that there is only one subtree with minimum sum and the given binary tree is not an empty tree.
Example
Given a binary tree:
return the node1
.
很经典,就是从leaf把值往上传,然后每到一个节点算一下sum,如果比global的小就更新一下。
Last updated