Problem
You get the root root of a binary tree. In a binary tree, each node has at most two children: a left child and a right child.
A level of the tree is the group of nodes at the same distance from the root. Return the node values level by level, as a list of lists.
Put the levels in order from the top level to the bottom level. In each level, put the values in order from left to right. For an empty tree, return an empty list.
The examples show each tree as a list in level order. This list gives the nodes row by row, from left to right. The value null marks a missing child.
Example 1
- Input:
- root = [6,2,8,1,4,7,9]
- Output:
- [[6],[2,8],[1,4,7,9]]
Example 2
- Input:
- root = [3,null,5,4]
- Output:
- [[3],[5],[4]]
- Explanation:
- Node
5is the right child of3, and node4is the left child of5. Each level has one node.
Example 3
- Input:
- root = []
- Output:
- []
Constraints
- 0 <= number of nodes <= 2000
- -1000 <= Node.val <= 1000
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Meta
Leetcode 102. Binary Tree Level Order Traversal
Reported Aug 4, 2025 · 4 source reports
MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View sourceVisa
Leetcode 102. Binary Tree Level Order Traversal
Reported Jun 8, 2026 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View sourceZscaler
Leetcode 102. Binary Tree Level Order Traversal
Reported Sep 3, 2026 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View source