【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 复制代码
相关推荐
ysu_03147 小时前
05 | 持久化撤销提示非核心功能
算法·游戏程序
浮沉9879 小时前
二分查找算法概述&通用模板
算法
Keven_1110 小时前
算法札记:SPFA判负环算法的证明
算法
什巳10 小时前
JAVA练习278- 和为 K 的子数组
java·学习·算法·leetcode
Jerry10 小时前
LeetCode 347. 前 K 个高频元素
算法
Young Doro11 小时前
SAC 算法
线性代数·算法·机器学习
罗超驿11 小时前
2.算法效率的核心密码:时间复杂度和空间复杂度详解
java·数据结构·算法
:-)11 小时前
算法-堆排序
数据结构·算法·排序算法