Given a binary tree, return the tilt of the whole tree.
The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree node values. Null node has tilt 0.
The tilt of the whole tree is defined as the sum of all nodes' tilt.
follow up是要去掉一个叶子,让总的tilt变得最小。
当时我想了一种greedy的方法,白板上的例子可以work,但是一时半会儿也
找不出反例。于是interviewer就说那如果不考虑时间复杂度呢,那就挨个删掉叶子
检查删掉谁后的节点最小。然后就是胡侃五分钟。
https://leetcode.com/problems/binary-tree-tilt/#/description