题目
官方way
1 | class Solution { |
一种抽象的思维:
- 抽象:硬币数 \(\rightarrow\) 负载量,考虑成: \(一个节点的负载量 = abs(硬币数-1)\)
- 节点间的硬币的移动数量:
abs(dfs(node->left))
+abs(dfs(node->right))
Reference
https://leetcode-cn.com/problems/distribute-coins-in-binary-tree/solution/zai-er-cha-shu-zhong-fen-pei-ying-bi-by-leetcode/