【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 复制代码
相关推荐
城管不管1 小时前
ReAct、Plan-and-Execute、Reflection 三大智能 Agent 范式核心区别
java·人工智能·算法·spring·ai·动态规划
月疯1 小时前
二分法算法(水平等分图形面积)
算法
豆瓣鸡2 小时前
算法日记 - Day3
java·开发语言·算法
白白白小纯2 小时前
算法篇—反转链表
c语言·数据结构·算法·leetcode
Achou.Wang2 小时前
深入理解go语言-第5章 并发编程——Go的灵魂
大数据·算法·golang
The Chosen One9852 小时前
高进度算法模板速记(待完善)
java·前端·算法
圣保罗的大教堂4 小时前
leetcode 3517. 最小回文排列 I 中等
leetcode
土豆.exe5 小时前
Fastjson2 2.0.53 哈希碰撞 RCE:从原理到三种打法
算法·哈希算法
黄河123长江5 小时前
有限Abel群的结构()
算法
Jerry6 小时前
LeetCode 92. 反转链表 II
算法