【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 复制代码
相关推荐
AI科技星18 小时前
微积分:变化与累积的数学(分层大白话解释版)
人工智能·算法·数学建模·数据挖掘·机器人
sinat_2869451918 小时前
llm wiki
人工智能·算法·chatgpt
Kiyra18 小时前
Agent 的记忆不是存数据库就行:上下文预算与轻量记忆的设计实战
数据库·人工智能·后端·面试·职场和发展·哈希算法
博界IT精灵19 小时前
图的遍历(哈喜老师)
数据结构·考研·算法·深度优先
sheeta199819 小时前
LeetCode 每日一题笔记 日期:2026.05.10 题目:2770. 达到末尾下标所需的最大跳跃次数
笔记·算法·leetcode
Halo_tjn19 小时前
基于异常处理机制 相关知识点
java·开发语言·算法
xingyuzhisuan19 小时前
适合微调Llama 3 70B模型的最低GPU配置推荐
运维·人工智能·算法·llama·gpu算力
IJCAST19 小时前
Exploring the Frontiers of Complexity: Latest Research from IJCAST
人工智能·深度学习·神经网络·算法
所以遗憾是什么呢?19 小时前
【题解】Codeforces Round 1097 (Div. 2, Based on Zhili Cup 2026) (致理杯) ABCDEF
数据结构·算法·acm·codeforces·icpc·ccpc·xcpc
wuweijianlove19 小时前
算法优化中的控制流重构与分支预测机制的技术7
算法·重构