
In a Meta mobile client, you may need to compact an integer buffer before rendering a Facebook feed module. Given an integer array nums, move all 0 values to the end of the array in place while keeping the relative order of all non-zero values unchanged.
Return the modified array.
nums, a list of integersExample 1
nums = [0, 1, 0, 3, 12][1, 3, 12, 0, 0]1, 3, 12 stay in the same order, and both zeroes are shifted to the end.Example 2
nums = [0, 0, 1][1, 0, 0]1 <= len(nums) <= 10^5-2^31 <= nums[i] <= 2^31 - 1nums = [0, 1, 0, 3, 12]Output[1, 3, 12, 0, 0]WhyThe non-zero elements keep their original order, and both zeroes move to the end.nums = [0, 0, 1]Output[1, 0, 0]WhyThe single non-zero value is moved to the front, and the rest of the array is filled with zeroes.nums = [4, 2, 1]Output[4, 2, 1]WhyThere are no zeroes, so the array remains unchanged.1 <= len(nums) <= 10^5-2^31 <= nums[i] <= 2^31 - 1The relative order of non-zero elements must be preservedThe array must be modified in placeAim for O(n) time and O(1) extra spacedef move_zeroes(nums):