Loading...
Loading...
Loading...
Print the tree one level per line. Each line holds the values of one level from left to right, separated by spaces.
Example 1
Input
3 9 20 null null 15 7
Output
3 9 20 15 7
Three levels.
Example 2
Input
1
Output
1
Try the problem first. Open one hint at a time.
A queue holds the nodes of the current level.
Replace it by the children of those nodes after printing.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor