Hardware interview practice
Move zeros to the end
Move every non-zero element to the left in its original order and place all zeros at the end, in place.
Reviewed example
Work through one case
Input
values = [0, 3, 0, 1, 2]Expected output
[3, 1, 2, 0, 0]Nonzero values keep their original order and every zero is moved to the suffix.
What to cover
Requirements
- Preserve non-zero order.
- Use no extra array.
- Write zeros into the vacated positions.
