Skip to content

Latest commit

 

History

History
4 lines (4 loc) · 398 Bytes

2019.07.29.md

File metadata and controls

4 lines (4 loc) · 398 Bytes

题目链接

https://leetcode-cn.com/problems/distribute-coins-in-binary-tree/

解题思路

参考官方题解。定义每个节点的过载量为root->val-N,而实际的过载量计算公式为root->val+dfs(root->left)+dfs(root->right)-1即为左子树的过载量与右子树的过载量之和减1。则每个子树需要调整的步数为左右子树的过载量绝对值的和。