【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 复制代码
相关推荐
JAVA面经实录9173 小时前
Java 数据结构与算法 (终极完整学习文档)
java·数据结构·算法
程序员三藏4 小时前
Web自动化测试详解
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
开源Z5 小时前
LeetCode 42 · 接雨水:从暴力到双指针的三步优化
算法·leetcode
旖-旎5 小时前
《LeetCode 695 岛屿的最大面积 FloodFill DFS 解法》
c++·算法·力扣·深度优先遍历·floodfill
syagain_zsx5 小时前
STL 之 vector 讲练结合
c++·算法
MartinYeung57 小时前
[论文学习]DP2Unlearning:高效且具保证的大型语言模型遗忘框架(基于差分隐私的 LLM Unlearning 方法)
学习·算法·语言模型
Tian_Hang7 小时前
C++原型模式(Protype)
开发语言·c++·算法
bIo7lyA8v7 小时前
算法复杂度的渐进分析与实际运行时间的差异的技术8
算法
yuan199978 小时前
欧拉梁静力与屈曲计算的 MATLAB 实现(有限差分法 + 解析解)
开发语言·算法·matlab