Loading problem…
You're building a data filtering feature that needs to move all zero values to the end of an array while maintaining the relative order of non-zero elements. This is common in data processing and UI filtering.
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Note that you must do this in-place without making a copy of the array.
// Example 1
let nums = [0,1,0,3,12];
moveZeroes(nums);
// nums becomes [1,3,12,0,0]
// Example 2
let nums = [0];
moveZeroes(nums);
// nums becomes [0]This problem models real frontend scenarios: