【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 复制代码
相关推荐
Navigator_Z14 小时前
LeetCode //C - 1328. Break a Palindrome
c语言·算法·leetcode
电科_银尘14 小时前
【大模型算法与工程 46】vLLM部署入门:模型服务、请求与运行观测
算法·vllm
AskHarries14 小时前
社区运营打法
算法
人间乄惊鸿客1 天前
c++ 右值
c++·算法
fanstuck1 天前
AI 客服答错了,三分钟分清是 Prompt 还是系统的锅
算法
田里的水稻1 天前
FA_编程算法200个分类列数-SUM
算法·分类·数据挖掘
猿人谷1 天前
从百万个 Pareto 解中选出 100 个:Riesz s-Energy 如何实现高效的多样性选择?
后端·算法·aigc
地平线开发者1 天前
地平线 × 同济无人车队:PointPillars 从浮点模型到 BPU 部署
算法·自动驾驶