【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 复制代码
相关推荐
学电子她就能回来吗5 分钟前
LeetCode Hot 100|普通数组专题学习笔记(零基础版)
笔记·算法·leetcode
用户老李7 分钟前
反向传播计算梯度举例
算法
niyongsheng8 分钟前
多智能体连续时间内路径规划:AA-SIPP(m) 的 Rust 实现与算法
算法·rust·机器人
招聘背调实务专家杨宏28 分钟前
上级评价出现主观偏差与口径冲突时如何校准
职场和发展
302wanger1 小时前
DeepSeek-V4.1-Flash-1017 免费用到1024,速来
算法
lisw051 小时前
微分与积分的本质区别解析
算法·数学建模·极限编程
xys_6782 小时前
深挖数据结构:树和二叉树(上)
数据结构·算法
Interview Aid1122 小时前
Google SWE Intern VO 面经:两轮 Coding,Follow-up 考察 BFS 状态
算法
琳达爱分享3 小时前
从单机令牌桶到集群限流:一次配额超发的复盘
后端·算法
职豚求职小程序3 小时前
中国铁塔2027届校招开启,网申怎么投、笔试面试怎么准备?
面试·职场和发展