Loading...
Loading...
Loading...
A job queue marks failed jobs with 0. Move all zeros to the end and keep the order of the other values. Do it in place.
Example
Input
6 0 4 0 7 9 0
Output
4 7 9 0 0 0
Zeros move to the back.
Try the problem first. Open one hint at a time.
Keep a write index for the next non-zero value.
Swap each non-zero item with the item at the write index, then move the write index on.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor