Back to exercises

Move Zeroes

Scan once, swap each non-zero value into the next write position, and advance that write pointer.

Coding Exercises Easy O(n)

Move Zeroes

Scan once, swap each non-zero value into the next write position, and advance that write pointer.

Move all zeroes to the end of the list while keeping the relative order of non-zero values.