Move Zeroes with Sorted Nonzero Values
Problem statement
Return an array containing all nonzero values from nums in ascending order, followed by the same number of zeroes as the input.
Function
moveZeroesSorted(nums: int[]) → int[]Examples
Example 1
nums = [0,3,0,1,2]return = [1,2,3,0,0]The nonzero values sort to 1,2,3 and two zeroes follow.
Example 2
nums = [0,0]return = [0,0]There are no nonzero values.
Constraints
0 <= nums.length <= 10^5.- Values are 32-bit signed integers.