【LeetCode 0102】【BSF】二叉树的层级遍历

  1. Binary Tree Level Order Traversal

Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).

Example 1:

复制代码
**Input:** root = [3,9,20,null,null,15,7]
**Output:** [[3],[9,20],[15,7]]

Example 2:

复制代码
**Input:** root = [1]
**Output:** [[1]]

Example 3:

复制代码
**Input:** root = []
**Output:** []

Constraints:

  • The number of nodes in the tree is in the range [0, 2000].
  • -1000 <= Node.val <= 1000
Idea
text 复制代码
借助于栈,实现BSF
javascript 复制代码
相关推荐
懒羊羊不懒@3 小时前
Java基础语法—最小单位、及注释
java·c语言·开发语言·数据结构·学习·算法
白云千载尽4 小时前
leetcode 912.排序数组
算法·leetcode·职场和发展
哆啦刘小洋4 小时前
Tips:预封装约束的状态定义
算法
代码充电宝4 小时前
LeetCode 算法题【简单】290. 单词规律
java·算法·leetcode·职场和发展·哈希表
Juan_20125 小时前
P1040题解
c++·算法·动态规划·题解
Onesoft%J1ao5 小时前
C++竞赛递推算法-斐波那契数列常见题型与例题详解
c++·算法·动态规划·递推·信息学奥赛
以己之5 小时前
NC313 两个数组的交集
算法·哈希算法
Brookty5 小时前
【算法】前缀和
java·学习·算法·前缀和·动态规划
And_Ii6 小时前
LeetCode 3397. 执行操作后不同元素的最大数量
数据结构·算法·leetcode
额呃呃6 小时前
leetCode第33题
数据结构·算法·leetcode