【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 复制代码
相关推荐
Oneshot2 小时前
DLX(Dancing Links)算法详解:求解数独最快的算法
算法
文丑颜不良啊2 小时前
LeetCode2541~2560题目解析
java·leetcode
青少儿编程课堂2 小时前
蓝桥杯青少组图形化 + 全国青少年信息素养大赛 + 电子学会Scratch考级:校园连连看解析
c++·python·算法·bfs·信息学竞赛
kongdong2 小时前
Hikyuu | RSI均值回归交易策略实现
算法·均值算法·回归·量化交易·交易策略·hikyuu
小王C语言3 小时前
优选算法:分治-归并排序
算法
小南家的青蛙4 小时前
微服务体系下DevOps运维岗位面试方案设计
运维·面试·职场和发展·devops
非优秀程序员13 小时前
第05章 播放器大战,暴风、快播与那一夜|《互联网产品恩仇录》
算法
文丑颜不良啊16 小时前
LeetCode2481~2500题目解析
java·leetcode
武子康20 小时前
驾驶轨迹换个坐标,就能给移动机器人用吗?
人工智能·算法·机器学习