【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 小时前
huawei 机考
算法·华为·深度优先
IronMurphy8 小时前
【算法四十三】279. 完全平方数
算法
墨染天姬8 小时前
【AI】Hermes的GEPA算法
人工智能·算法
papership9 小时前
【入门级-数据结构-3、特殊树:完全二叉树的数组表示法】
数据结构·算法·链表
smj2302_796826529 小时前
解决leetcode第3911题.移除子数组元素后第k小偶数
数据结构·python·算法·leetcode
Beginner x_u9 小时前
链表专题:JS 实现原理与高频算法题总结
javascript·算法·链表
wxy不爱写代码9 小时前
C++多线程
面试·职场和发展
野生技术架构师12 小时前
金三银四面试总结篇,汇总 Java 面试突击班后的面试小册
java·面试·职场和发展
_深海凉_12 小时前
LeetCode热题100-寻找两个正序数组的中位数
算法·leetcode·职场和发展
ja哇13 小时前
大厂面试高频八股
java·面试·职场和发展