Loading...
Loading...
Loading...
A ticket tool shows ids newest first, but they arrive oldest first. Read the list and print it in reverse order. Use two pointers; do not use reverse() or slicing.
Example
Input
5 1 2 3 4 5
Output
5 4 3 2 1
Reversed.
Try the problem first. Open one hint at a time.
Keep an index at each end of the list.
Swap the two items, move both indexes inward, and stop when they meet.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor