【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 复制代码
相关推荐
大侠归来16 小时前
C 语言 | 在函数中操作数组
c语言·c++·算法
怕浪猫21 小时前
GEO 优化到底是什么?AI时代内容创作者必须懂的新技能
算法·面试·github
朝朝辞暮i1 天前
C++ 第 23 课:class —— 开始真正进入面向对象
开发语言·c++·算法
Evand J1 天前
【MATLAB例程】三维RRT+APF避障路径规划与到达角(AOA)定位算法|三维路径优化与定位仿真例程
算法·matlab·路径规划·代码·定位·rrt·aoa
weixin_307779131 天前
有限产能智能排产与动态重排智能体:从需求解构到技术实现
开发语言·人工智能·算法·架构
朝朝辞暮i1 天前
C++ 第 27 课:智能指针 shared_ptr
开发语言·c++·算法
朝朝辞暮i1 天前
C++ 第 29 课:回调函数 Callback
开发语言·c++·算法
ychqsq1 天前
207.炸酱面
经验分享·职场和发展
Godspeed Zhao1 天前
现代智能雷达技术14——算法(0)
线性代数·算法·雷达
可乐ea1 天前
Agent 模型分级升级路由:用置信度阈值把贵模型省下来
人工智能·算法·机器学习·结构化输出·置信度路由·模型升级路由·大模型成本优化