【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 复制代码
相关推荐
EdmundXjs9 小时前
大模型核心概念解读
人工智能·算法
lookaroundd9 小时前
llm-compressor 普通量化调用链分析
python·算法
中小企业实战军师刘孙亮9 小时前
家居建材营销新趋势:数字化、体验式与可持续方向-佛山鼎策创局破局增长咨询有限公司
职场和发展·产品运营·创业创新·需求分析·学习方法
小羊在睡觉9 小时前
力扣239. 滑动窗口最大值
数据结构·后端·算法·leetcode·go
兰令水9 小时前
topcode【随机算法题】【2026.5.20打卡-java版本】
java·开发语言·算法
此生决int10 小时前
算法从入门到精通——前缀和
c++·算法·蓝桥杯
凯瑟琳.奥古斯特10 小时前
传输层核心功能解析
开发语言·网络·职场和发展
大大杰哥10 小时前
leetcode hot100(4)矩阵
算法·leetcode·矩阵
小白|10 小时前
cmake:昇腾CANN构建系统完全指南
java·c++·算法
nebula-AI10 小时前
人工智能导论:模型与算法(未来发展与趋势)
人工智能·神经网络·算法·机器学习·量子计算·automl·类脑计算