Complete the level loop
Warm-up · Fill in the code · about 5 min
Fill the three blanks so levelOrder returns the values of each level as its own list.
Example 1
Input:
[[3,9,20,null,null,15,7]]
Output:
[[3],[9,20],[15,7]]
Constraints
- 0 ≤ number of nodes ≤ 1,000
- -1,000 ≤ Node.val ≤ 1,000
- The tree is given in level order; null marks a missing child
Learn the idea first: Level-order traversal, a visual lesson.
More Level-order traversal problems
- Who leaves the queue next? Warm-up
- Level order Standard
- Right side view Standard
- Average of levels Standard
- Zigzag level order Challenge