Move All Zeros to the Beginning of the Array
Move all zeros to the left of an array while maintaining its order.
Statement
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.
Example
Let’s look at the following integer array:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.