【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 复制代码
相关推荐
大熊背14 小时前
ISP图像处理中大数乘法溢出处理(一)
人工智能·python·算法·溢出处理
wabs66615 小时前
关于栈【力扣1047. 删除字符串中的所有相邻重复项的思考】
数据结构·c++·算法·leetcode··代码随想录
疯狂打码的少年15 小时前
【数据结构】选择类排序:简单选择与堆排序
java·数据结构·笔记·算法
晚风醉蝶16 小时前
1-16-计数排序-CountingSort
python·算法·排序算法
疯狂打码的少年16 小时前
【数据结构】排序算法:归并排序与基数排序
数据结构·笔记·算法·排序算法
ychqsq16 小时前
122.收网
经验分享·职场和发展
fb_1234516 小时前
Shell 脚本从 0 到精通|脚本规范 + 变量 + 数值运算 + 条件测试(可直接复制,面试必备)
chrome·面试·职场和发展
吃旺旺雪饼的小男孩16 小时前
U-Net 语义分割详解:原论文、PyTorch 实现与真实消融实
人工智能·pytorch·python·算法
lucas_AI16 小时前
35 种开源文档抽取配置,只有 4 个跨过 F1 0.5
人工智能·算法·llm
YSoup16 小时前
2026 安卓面试助手APP(安卓八股、题库)
android·面试·职场和发展