leetcode-979-Distribute Coins in Binary Tree

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zem_nezer/article/details/86608438

Hard, it is impossible to think exactly movement of a tree, all we need to do is know how many coin is useless/excess in current subtree, then report it to root and we are done. During that time, we calculate the total move.

Error:

  1. do not know what res store: it store the total move of its subtree
  2. do not know what return’s return: it return how many coin excess in current subtree

猜你喜欢

转载自blog.csdn.net/zem_nezer/article/details/86608438