【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 复制代码
相关推荐
Frostnova丶7 小时前
【算法笔记】数学知识
笔记·算法
吴可可1237 小时前
AutoCAD 2016与2014二次开发关键差异
算法
雨白8 小时前
哈希:以时间换空间的算法实战
算法
San813_LDD10 小时前
[数据结构]LeetCode学习
数据结构·算法·图论
x1387028595710 小时前
c语言排雷游戏(基础版9*9)
c语言·算法·游戏
sheeta199811 小时前
LeetCode 每日一题笔记 日期:2026.06.06 题目:2196. 根据描述创建二叉树
笔记·算法·leetcode
小欣加油11 小时前
leetcode994 腐烂的橘子
数据结构·c++·算法·leetcode·bfs
QuZero12 小时前
Guava Cache Deep Dive
java·后端·算法·guava
随意起个昵称12 小时前
线性dp-LIS题目4(A Twisty Movement)
算法·动态规划