【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 复制代码
相关推荐
Raink老师20 小时前
【AI面试临阵磨枪-62】设计基于 RAG 的内部知识库问答平台(多租户、权限、文件上传、实时更新)
人工智能·面试·职场和发展
smj2302_796826521 天前
解决leetcode第3943题递增后的数对数量
数据结构·python·算法·leetcode
炽烈小老头1 天前
【每天学习一点算法 2026/05/25】矩阵中的最长递增路径
学习·算法·矩阵
我爱cope1 天前
【Agent智能体6 | 智能体AI评估】
人工智能·职场和发展
叁散1 天前
实验报告:5G 仿真环境与基本链路模拟
算法
从负无穷开始的三次元代码生活1 天前
算法零碎灵感点分享
算法
染指11101 天前
9.LangChain框架(实现RAG)
数据库·人工智能·算法·机器学习·ai·大模型
我爱cope1 天前
【Agent智能体5 | 任务分解:识别工作流中的步骤】
人工智能·职场和发展
大数据三康1 天前
在spyder进行的遗传算法练习
开发语言·python·算法
Gene_20221 天前
轮式底盘的微分平坦
算法