Move All Zeros to the Beginning of the Array

Move all zeros to the left of an array while maintaining its order.


We’re given an integer array, nums. Move all zeroes, if any, to the left while maintaining the order of other elements in the array. All changes must be made in nums itself; no return value is expected.


Let’s look at the following integer array:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.