Binary Tree Level Order Traversal II
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).
(从底向上按层遍历二叉树)
Example:
1. 递归
按层遍历,每次都把同层的树节点 Node 组合成一个 List 输入到队列。(变形之后的BFS)。(只需要把Binary Tree Level Order Traversal结果倒叙存储即可) 具体实现过程如下:
1 | # Definition for a binary tree node. |