【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 复制代码
相关推荐
悲伤小伞12 小时前
LeetCode 热题 100_4-283. 移动零
算法·leetcode·职场和发展
星 海13 小时前
网络芯片对IP地址最长前缀匹配算法的实现
网络·算法
OYangxf13 小时前
力扣hot100【滑动窗口】
算法·leetcode·职场和发展
CQU_JIAKE13 小时前
5.7【A】
算法
2zcode13 小时前
基于SVM与HOG算法的行人检测系统设计与实现
算法·机器学习·支持向量机
MATLAB代码顾问13 小时前
MATLAB实现粒子群算法优化PID参数
开发语言·算法·matlab
翎沣13 小时前
C++11异常处理机制
java·c++·算法
火花怪怪13 小时前
Origin分析外量子效率(EQE, External Quantum Efficiency)数据处理-EQE计算带隙
算法·数据分析
上弦月-编程13 小时前
异或法巧解数组中两独数
数据结构·算法
risc12345613 小时前
维特比算法(Viterbi Algorithm)
算法