Loading...
Loading...
Loading...
Print the tree one level per line. The first line goes left to right, the second line right to left, the third left to right again, and so on. Values are separated by spaces.
Example 1
Input
3 9 20 null null 15 7
Output
3 20 9 15 7
The second line is reversed.
Example 2
Input
1 2 3 4 5 6 7
Output
1 3 2 4 5 6 7
Try the problem first. Open one hint at a time.
Collect the levels first.
Reverse every second one with a slice.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor