【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 复制代码
相关推荐
Hush_NUIST2 小时前
C++_sizeof的相关知识点
开发语言·c++·算法·面试
苍狼王unity学院3 小时前
C#列表按照日期进行从大到小排序
算法·unity·c#·游戏引擎·排序算法
new60ll3 小时前
决策树基础
算法·决策树·机器学习
励志秃头码代码5 小时前
面试笔记 8.5
java·面试·职场和发展
王小王-1236 小时前
基于Boost算法的贷款违约预测研究
人工智能·算法·贷款违约预测·基于boosting算法
UestcXiye6 小时前
Leetcode3227. 字符串元音游戏
c++·leetcode·游戏·数据结构与算法
黑不溜秋的6 小时前
C++ 几何算法 - 向量点乘,叉乘及其应用
c++·算法·几何学
betterManchester7 小时前
面试经典算法150题系列-h指数
数据结构·算法·面试
sjtu_cjs7 小时前
贪心算法part03
windows·算法·贪心算法
向阳逐梦7 小时前
Ubuntu系统上定制文件系统
算法·程序员·架构