Medium · Trees
Level order
Given the root of a binary tree, return its level-order traversal: a list of levels from top to bottom, each holding that level's node values from left to right. An empty tree has no levels (the reference returns null).
Examples
Example 1
[3,9,20,·,·,15,7]Output: [3] [9,20] [15,7]
Example 2
[1,2,3,4,5,6,7]Output: [1] [2,3] [4,5,6,7]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.