
In a Meta Reels client buffer, 0 represents an empty placeholder frame. Given an integer array nums, move all zeroes to the end in-place while keeping the relative order of the non-zero elements.
Return the modified array after the transformation.
nums, a list of integersExample 1
Input: nums = [0, 1, 0, 3, 12]
Output: [1, 3, 12, 0, 0]
Explanation: The non-zero values 1, 3, 12 stay in the same order, and both zeroes move to the end.
Example 2
Input: nums = [0, 0, 1]
Output: [1, 0, 0]
Explanation: Only one non-zero value exists, so it moves to the front and the remaining positions become zero.
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 values are collected in order as `1, 3, 12`, and the two zeroes are placed at the end.nums = [0, 0, 1]Output[1, 0, 0]WhyThe only non-zero value moves to the front, and both remaining positions are zero.nums = [4, 5, 6]Output[4, 5, 6]WhyThere are no zeroes, so the array remains unchanged.1 <= len(nums) <= 10^5-2^31 <= nums[i] <= 2^31 - 1The array must be modified in-placeThe relative order of non-zero elements must be preserveddef move_zeroes(nums):