【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 复制代码
相关推荐
文丑颜不良啊11 小时前
LeetCode1941~1960题目解析
java·leetcode
MUSHANGXS13 小时前
大模型时代的新蓝海-基于OS底层的AI-Agent应用
人工智能·职场和发展·交互
老师我太想进步了202614 小时前
【数据结构-4】算法美学之顺序表
数据结构·算法
风影同志7832414 小时前
编码器是激活函数吗?—— 一个看起来很像、其实不是的类比
算法
UIU11414 小时前
P1481 魔族密码
c++·算法·动态规划
文丑颜不良啊15 小时前
LeetCode1961~1980题目解析
java·leetcode
文丑颜不良啊16 小时前
LeetCode2001~2020题目解析
java·leetcode
加宝的起点雷达18 小时前
40 条候选里 38 条来自同一个源,主卡整屏重样
人工智能·算法·创业
秋天的怀念_David18 小时前
算法一千零一夜 · 第二十六夜 协议的母语
java·spring boot·算法