283. Move Zeroes
Intitution
Instead of moving non-zeros forward and filling zeros later use two pointers (i
and j
) place non-zero elements at the correct spot (j
) also immediately sets the current i
to 0
if a movement has occurred
So, it shifts non-zeros forward and backfills zeros in one go
Complexity
Space Complexity
Time Complexity
Code
Last updated