Given an array of integers nums, move all zeros to the end of the array while preserving the relative order of the non-zero elements. Return the modified array.
For example, given [0, 1, 0, 3, 12], the result should be [1, 3, 12, 0, 0].
nums = [0, 1, 0, 3, 12][1, 3, 12, 0, 0]nums = [0, 0, 0][0, 0, 0]nums = [1, 2, 3][1, 2, 3]0 <= nums.length <= 10^4-10^9 <= nums[i] <= 10^9Run your code to see results
Use Cmd+Enter to run