Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).
(按层遍历二叉树)
Example:
1. 递归
按层遍历,每次都把同层的树节点 Node 组合成一个 List 输入到队列。(变形之后的BFS)。
1 | # Definition for a binary tree node. |