【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 复制代码
相关推荐
普通攻击往后拉3 小时前
Leetcode 206. 反转链表
算法·leetcode·链表
@syh.4 小时前
【贪心】矩阵消除游戏
算法·游戏·矩阵
可编程芯片开发4 小时前
基于零极点配置的PID控制系统simulink建模与仿真
算法
徐小夕5 小时前
开源!我用SQLite + DuckDB打造了一款可视化AI问数平台
前端·算法·github
Hrain-AI5 小时前
2026 企业 AI 智能体平台横评:8 大主流平台 7 维度实测对比
人工智能·算法·机器学习
Angel Q.6 小时前
因子分析和生成模型有什么关系?从“幕后因素”到“生成数据”
算法
咩咩啃树皮7 小时前
第52篇:前端工程化完整体系精讲——Vite构建、模块化、打包原理、规范体系、面试终极通关
前端·面试·职场和发展
FBI HackerHarry浩7 小时前
AI大模型开发V2第四阶段线性回归
人工智能·算法·线性回归
Jerry8 小时前
LeetCode 108. 将有序数组转换为二叉搜索树
算法