【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 复制代码
相关推荐
偷吃的耗子15 小时前
[CNN算法理解]:二、卷积层(从生活实例到技术细节)
算法·cnn·生活
2301_7903009615 小时前
C++与Docker集成开发
开发语言·c++·算法
TracyCoder12315 小时前
LeetCode Hot100(22/100)——141. 环形链表
算法·leetcode·链表
一起养小猫15 小时前
Flutter for OpenHarmony 进阶:递归算法与数学证明深度解析
算法·flutter
赛博云推-Twitter热门霸屏工具15 小时前
Twitter 搜索霸屏的关键词工程方法——从算法理解到赛博云推的系统化执行
算法·twitter·dreamweaver
罗湖老棍子16 小时前
【区间DP】括号序列:如何求解最长合法子序列?(POJ 2955)
算法·动态规划·区间dp·区间动态规划·端点匹配型
王德博客16 小时前
【实现常见排序算法】直接插入排序的算法思想
数据结构·算法·排序算法
m0_5648768416 小时前
分布式训练DP与DDP
人工智能·深度学习·算法
纤纡.16 小时前
逻辑回归实战进阶:交叉验证与采样技术破解数据痛点(一)
算法·机器学习·逻辑回归
重生之后端学习16 小时前
146. LRU 缓存
java·数据结构·算法·leetcode·职场和发展