【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 复制代码
相关推荐
无限进步_几秒前
138. 随机链表的复制 - 题解与详细分析
c语言·开发语言·数据结构·算法·链表·github·visual studio
烟花落o4 分钟前
【数据结构系列04】随机链表的复制、环形链表I、环形链表||
数据结构·算法·leetcode·链表
senijusene5 分钟前
Linux软件编程: 线程属性与线程间通信详解
java·linux·jvm·算法
weiabc5 分钟前
cout << fixed << setprecision(2) << v; fixed 为什么不用括号,它是函数吗
开发语言·c++·算法
m0_531237177 分钟前
C语言-内存函数
c语言·开发语言·算法
独自破碎E11 分钟前
【DFS】BISHI77数水坑
算法·深度优先
小陈phd8 小时前
多模态大模型学习笔记(七)——多模态数据的表征与对齐
人工智能·算法·机器学习
雨泪丶8 小时前
代码随想录算法训练营-Day35
算法
pursuit_csdn9 小时前
LeetCode 1022. Sum of Root To Leaf Binary Numbers
算法·leetcode·深度优先
NAGNIP10 小时前
一文搞懂神经元模型是什么!
人工智能·算法