📚 PracticeMediumAlgorithm ProblemCoding Ready
Binary Tree Level Order Traversal
treebfsqueue
LeetCode #102
Updated Dec 20, 2025
Question
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).
LeetCode: Binary Tree Level Order Traversal
Example:
Input: root = [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]
3
/ \
9 20
/ \
15 7
Level 0: [3]
Level 1: [9, 20]
Level 2: [15, 7]
Hints
Hint 1
Use a queue to process nodes level by level. This is a classic BFS pattern.
Hint 2
The key trick: capture the queue size at the start of each level, then process exactly that many nodes.
Hint 3
If you don't capture the size, the queue grows during the loop and you'll mix levels together.
Your Solution
python
Auto-saves every 30s
Try solving the problem first before viewing the solution
0:00time spent