【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 复制代码
相关推荐
ZPC82106 小时前
YOLO26 识别串番茄果梗
人工智能·深度学习·算法·机器学习
景熙55236 小时前
14.Java 集合框架从入门到源码万字详解(含 ArrayList/LinkedList/HashMap 源码、泛型通配符、红黑树)
java·开发语言·数据结构·算法
aaaameliaaa6 小时前
结构体 结构体
c语言·笔记·算法
有Li7 小时前
【AI答疑】MR数据预处理步骤
人工智能·笔记·算法·语言模型·医学生
yuanxi2008 小时前
圣湘生物的三重转变:用PSS⁵价值力看懂从卖单品到卖经营价值
职场和发展·创业创新·学习方法
盛世宏博北京8 小时前
多传感器数据融合算法:实现档案库房温湿度全域无死角监测
算法·档案温湿度
AgentMaster9 小时前
零售行业智能客服系统怎么选?3 大场景落地与 4 款平台对比实践
大数据·人工智能·算法
Nil2089 小时前
leetcode 394字符串解码
leetcode
远航计算机9 小时前
客服记录怎么变成 AI 会引用的内容?五步清洗法
大数据·人工智能·算法·aigc
码流子9 小时前
几万路监控怎么接:高速公路视频汇聚平台的架构设计与落地坑点
大数据·人工智能·物联网·算法·架构