【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 复制代码
相关推荐
维克兜率天8 分钟前
4.1.3 策略类型全景图:六大策略,你适合哪个
笔记·python·算法·量化
01_ice13 分钟前
c++类和对象(中)
c++·算法
纪念 22916 分钟前
数据结构排序(一)
数据结构·算法·排序算法
薛定e的猫咪19 分钟前
(NeurIPS 2021)MatNet:面向矩阵型关系数据的神经组合优化编码器
人工智能·深度学习·线性代数·算法·矩阵
高亦真33 分钟前
今天是学习嵌入式的第32天
linux·学习·算法
鹿角片ljp9 小时前
LeetCode 236. 二叉树的最近公共祖先|递归后序
算法
luj_17689 小时前
大律师考核应重能力与科技素养
c语言·开发语言·c++·经验分享·算法
无定义_9 小时前
Floyd——Warshall
算法
刃神太酷啦9 小时前
Linux 系统 MySQL 完整安装配置教程:从卸载 MariaDB 到优化 my.cnf----《Hello MySQL!》(1)
android·linux·c语言·c++·mysql·leetcode·mariadb
带多刺的玫瑰10 小时前
Leecode#9刷题之回文数
数据结构·算法