mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
40 lines
537 B
Markdown
40 lines
537 B
Markdown
# [102. Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)
|
|
|
|
## 题目
|
|
|
|
|
|
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
|
|
|
|
For example:
|
|
Given binary tree [3,9,20,null,null,15,7],
|
|
|
|
```c
|
|
3
|
|
/ \
|
|
9 20
|
|
/ \
|
|
15 7
|
|
```
|
|
|
|
return its level order traversal as:
|
|
|
|
```c
|
|
[
|
|
[3],
|
|
[9,20],
|
|
[15,7]
|
|
]
|
|
```
|
|
|
|
|
|
## 题目大意
|
|
|
|
按层序从上到下遍历一颗树。
|
|
|
|
## 解题思路
|
|
|
|
用一个队列即可实现。
|
|
|
|
|
|
|