1 / 2 3 / \ 4 5
[4, 5, 3], [2], [1]
.[4, 5, 3]
would result in this tree:1 / 2
[2]
would result in this tree:1
[1]
would result in the empty tree:[]
[4, 5, 3], [2], [1]
.
https://www.youtube.com/watch?v=2vwTmHTL1Mk&ab_channel=XavierElon
这题还比较新(对我),解决办法是计算每个node的height,子节点是0,网上走,root = Math。max(left,right)+ 1。root==null就返回-1.
然后看是否需要加入新的ArrayList,然后把相同height的node加到对应的list中
366. Find Leaves of Binary Tree
原文:https://www.cnblogs.com/wentiliangkaihua/p/14965487.html