Given an array of integers, move all zeros present in the array to the end. The solution should maintain the relative order of items in the array. Return the modified array.
Let array arr
equal to [ 6, 0, 8, 2, 3, 0, 4, 0, 1 ]
. Once zeros are moved to the end of the array, it will look like [ 6, 8, 2, 3, 4, 1, 0, 0, 0 ]
. The solutions should return this array.