Loading...
Loading...
Loading...
Print the values of the tree in preorder order, separated by single spaces. Preorder handles a node first, then its left side, then its right side.
Example 1
Input
1 2 3 4 5 null 6
Output
1 2 4 5 3 6
Prints 1 2 4 5 3 6.
Example 2
Input
5
Output
5
Try the problem first. Open one hint at a time.
Write the node's value before the two recursive calls.
Use one list that all calls add to.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor