【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 复制代码
相关推荐
什巳6 小时前
JAVA练习309- 二叉树的层序遍历
java·数据结构·算法·leetcode
什巳9 小时前
JAVA练习306- 翻转二叉树
java·数据结构·算法·leetcode
smj2302_796826529 小时前
解决leetcode第3989题网格中保持一致的最大列数
python·算法·leetcode
ychqsq9 小时前
88.归途
经验分享·职场和发展
巧克力男孩dd10 小时前
Python超典型练习题(第一次作业)
开发语言·python·算法
爱刷碗的苏泓舒10 小时前
平方根信息滤波:矩阵推导及 GNSS 参数估计应用
线性代数·算法·矩阵·gnss·参数估计·测量平差·平方根信息滤波
想做小南娘,发现自己是女生喵11 小时前
第 2 章 顺序表和 vector
java·数据结构·算法
艾醒12 小时前
2026年第29周(7.13-7.19)AI全复盘:技术突破、行业趣闻翻车、算力服务器商业动态
人工智能·算法
雪碧聊技术12 小时前
动态规划算法—01背包问题
算法·动态规划
bu_shuo12 小时前
c与cpp中的argc和argv
c语言·c++·算法