【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 复制代码
相关推荐
xushichao198917 小时前
实时数据压缩库
开发语言·c++·算法
minji...17 小时前
Linux 文件系统 (三) 软连接和硬链接
linux·运维·服务器·c++·算法
故事和你9118 小时前
sdut-python-实验四-python序列结构(21-27)
大数据·开发语言·数据结构·python·算法
memcpy018 小时前
LeetCode 1456. 定长子串中元音的最大数目【定长滑窗模板题】中等
算法·leetcode·职场和发展
liuyao_xianhui18 小时前
优选算法_模拟_提莫攻击_C++
开发语言·c++·算法·动态规划·哈希算法·散列表
玛丽莲茼蒿18 小时前
LeetCode hot100【相交链表】【简单】
算法·leetcode·职场和发展
罗湖老棍子18 小时前
They Are Everywhere(Codeforces- P701C)
算法·滑动窗口·codeforce题解
wen__xvn18 小时前
力扣模拟题刷题
算法·leetcode
bbbb36518 小时前
算法复杂度与能耗关系的多变量分析研究的技术7
算法
不要秃头的小孩18 小时前
力扣刷题——111.二叉树的最小深度
数据结构·python·算法·leetcode