【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 复制代码
相关推荐
随意起个昵称1 小时前
区间dp-基础题目1(石子合并)
算法·动态规划
吞下星星的少年·-·2 小时前
线段树模板
算法
段一凡-华北理工大学2 小时前
2026 高炉炼铁智能化技术全景与演进路径~系列文章11:演进路径与行业未来
大数据·网络·人工智能·算法·工业智能体·高炉炼铁智能化
凯瑟琳.奥古斯特2 小时前
高阶子查询题目精炼
开发语言·数据库·python·职场和发展·数据库开发
叶小鸡2 小时前
小鸡玩算法-力扣HOT100-多维动态规划
算法·leetcode·动态规划
星马梦缘3 小时前
aaaaa
数据结构·c++·算法
菜菜的顾清寒3 小时前
力扣HOT100(42)链表-随机链表的复制
算法·leetcode·链表
lqqjuly3 小时前
模型剪枝与稀疏化:理论、算法与可运行实现
人工智能·算法·剪枝
凯瑟琳.奥古斯特4 小时前
数据库原理选择题精选
数据库·python·职场和发展
逻辑君4 小时前
Foresight研究报告【20260011】
人工智能·线性代数·算法·矩阵