- leetcode BFS+DFS
- Leetcode PHP题解--D125 107. Binary
- leetcode:107. Binary Tree Level
- 107. Binary Tree Level Order Tra
- Binary Tree Zigzag Level Order T
- Leetcode-103题:Binary Tree Zigzag
- [Leetcode] 88. Binary Tree Zigza
- [Leetcode] 73. Binary Tree Zigza
- 107. Binary Tree Level Order Tra
- Q107 Binary Tree Level Order Tra
二叉树的层序遍历

代码:
定义队列,先进先出,定义变量toBePrint和nextPrint,toBePrint为将要打印的个数,nextPrint为下一层要打印的个数。然后存储到res中,输出的时候需要从叶子层输出,所以弄了另一个res1,倒序输出res。

网友评论