Skip to main content

Practice · 3 of 6

Move zeros in place

CHALLENGE
Difficulty: intermediate+25 XP

Implement void moveZeros(int[] arr): all zeros to the end, in place, preserving non-zero order. Two passes: compact non-zeros forward with a write index, then zero-fill the tail.

Back to lesson: Practice: Array lab