【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 小时前
【论文阅读】世界模型发展脉络整理---Understanding World or Predicting Future? A Comprehensive Survey of World Models
论文阅读·人工智能·算法·机器人
灵智实验室14 小时前
PX4状态估计技术EKF2详解(四):EKF2 Output Predictor——从延迟估计到实时输出
算法·无人机·px 4
科研小白_14 小时前
【MATLAB点云处理基础】基于区域生长算法的桥墩面域点云分割
算法
paeamecium14 小时前
【PAT甲级真题】- Shuffling Machine (20)
c++·算法·pat考试·pat
m0_7375393714 小时前
pod Scheduler调度
算法·贪心算法
此生决int14 小时前
算法从入门到精通——双指针
算法
普马萨特14 小时前
Uber H3:地理网格索引在空间数据分析中的应用
数据结构·算法
alphaTao15 小时前
LeetCode 每日一题 2026/5/11-2026/5/17
算法·leetcode
洛水水15 小时前
【力扣100题】45.零钱兑换
算法·leetcode·职场和发展
Aaron158815 小时前
全频段 SDR干扰源模块解决方案(星链干扰、LORA无人机干扰)
人工智能·算法·fpga开发·硬件架构·硬件工程·无人机·信息与通信