
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 - 1