【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 复制代码
相关推荐
NEFU_Jyj11 小时前
牛客周赛R168
算法
文丑颜不良啊18 小时前
LeetCode2221~2240题目解析
java·leetcode
Navigator_Z18 小时前
LeetCode //C - 1317. Convert Integer to the Sum of Two No-Zero Integers
c语言·算法·leetcode
D e re k ZH19 小时前
C++ 标准库算法全景指南
数据结构·c++·算法
冻柠檬飞冰走茶20 小时前
字母移动游戏题解:贪心求最长可保留连续子串(附 C 实现)
c语言·开发语言·数据结构·算法·动态规划
文丑颜不良啊20 小时前
LeetCode2161~2180题目解析
java·leetcode
雪落漂泊20 小时前
C++算法 二分查找篇(上)
开发语言·c++·算法
文丑颜不良啊1 天前
LeetCode2141~2160题目解析
java·leetcode
LabVIEW开发1 天前
LabVIEW 连接板:28 个端子怎么排,优先级怎么定
java·算法·labview