
In a Meta-style feed processing task, you are given a list of integers and need to shift all non-zero values to the left side of the list while keeping their original relative order. All zeros should be moved to the right.
Write a function that modifies the list in place and returns it.
numsExample 1
nums = [0, 1, 0, 3, 12][1, 3, 12, 0, 0]1, 3, and 12 stay in the same order and are compacted to the left.Example 2
nums = [4, 0, 5, 0, 0, 2][4, 5, 2, 0, 0, 0]1 <= len(nums) <= 10^5-10^9 <= nums[i] <= 10^9nums = [0, 1, 0, 3, 12]Output[1, 3, 12, 0, 0]WhyThe non-zero values are `1`, `3`, and `12`, and they keep their original order after being moved left.nums = [4, 0, 5, 0, 0, 2]Output[4, 5, 2, 0, 0, 0]WhyThe values `4`, `5`, and `2` are compacted to the front, and the remaining positions become zero.nums = [1, 2, 3]Output[1, 2, 3]WhyThere are no zeros, so the array remains unchanged.1 <= len(nums) <= 10^5-10^9 <= nums[i] <= 10^9Preserve the relative order of non-zero elementsModify the list in place using O(1) extra spacedef move_non_zero_left(nums):