【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 复制代码
相关推荐
文丑颜不良啊13 小时前
LeetCode2521~2540题目解析
java·leetcode
lisw0513 小时前
Dayhoff的PAM替换矩阵理论评介!
线性代数·算法·矩阵
一起学安全技术14 小时前
拆大模型 03|注意力的一句话版本:不用论文讲清 Attention
深度学习·算法·语言模型·transformer
Delightrs15 小时前
Rust LeetCode238 算法题解
开发语言·算法·rust
自信1504130575916 小时前
重生之从0开始学习c++之——vector-中篇
c++·学习·算法
文丑颜不良啊16 小时前
LeetCode2501~2520题目解析
java·leetcode
lsc_blog21 小时前
年终自评别贴提交记录,把技术产出讲成变化
数据库·面试·职场和发展·跳槽·求职招聘
GoAI1 天前
DeepSeek Harness Memory (一)主流记忆插件总结
后端·算法·面试
Pniubi1 天前
力扣54.螺旋矩阵
算法·leetcode·矩阵