问题:
Given a binary tree, return the bottom-up level order traversal of its nodes' values....(ie, from left to right, level by level from leaf to root)....例子:
给出二叉树 [3,9,20,null,null,15,7],
image.png
返回从下到上的层级序列为:
[
[15,7],
[9,20],
[3]
]
思路...:
这道题比较麻烦,要遍历二叉树,返回反过来顺序的二阶List。...有两种方法,也就是经常说到的DFS深度优先遍历和BFS广度优先遍历。
BFS:
广度优先遍历就是一层层地攻略过去,把每一层的所有节点都记录下来再走向下一层。