【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 复制代码
相关推荐
曹牧1 小时前
C#:数字的定义和表示方式
算法·c#
Nil2081 小时前
leetcode 138随机链表的复制
算法·leetcode·链表
疯狂打码的少年3 小时前
【数据结构】图的遍历:深度优先搜索(DFS)
数据结构·笔记·算法·深度优先
-凌凌漆-4 小时前
【freertos】Task创建(v2)
java·开发语言·算法
Nil2084 小时前
leetcode 24两两交换链表中的节点
算法·leetcode·链表
.格子衫.4 小时前
033动态规划之状态压缩DP——算法备赛
算法·动态规划
ysa0510305 小时前
c++常用自带函数用法与注意
c++·笔记·算法
带多刺的玫瑰6 小时前
Leecode#4刷题之寻找两个正序数组的中位数
java·前端·算法
土司大王6 小时前
LeetCode hot100——除了自身以外数组的乘积
数据结构·算法·leetcode