【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 复制代码
相关推荐
Cx330_FCQ1 小时前
Tmux使用
服务器·git·算法
拳里剑气2 小时前
C++算法:多源BFS
c++·算法·宽度优先·多源bfs
ysa0510303 小时前
【板子】短序列dp(换成维护更小常数维度的dp)
c++·笔记·算法·板子
shwill1233 小时前
PID 算法(三)--- 增量 PID ↔ 单神经元 PID 等价映射
linux·算法
wabs6664 小时前
关于图论【卡码网110.字符串迁移的思考】
数据结构·算法·图论
hanlin034 小时前
刷题笔记:力扣第242、349题(哈希表)
笔记·算法·leetcode
浮沉9875 小时前
二分查找算法例题(二)
算法
only-qi6 小时前
大模型Agent面试攻略:落地工程痛点、评估体系与Agentic RAG核心精讲
人工智能·算法·面试·职场和发展·langchain·rag
数字宝藏6 小时前
15本电子书分享
职场和发展·职场发展·教育电商
Gauss松鼠会8 小时前
【GaussDB】GaussDB锁阻塞源头查询
java·开发语言·前端·数据库·算法·gaussdb·经验总结