class Solution {
public void moveZeroes(int[] nums) {
int len=nums.length,low=0,high=0;
while(high<len){
if(nums[high]!=0){
swap(nums,low,high);
low++;
}
high++;
}
}
public void swap(int[] nums, int left, int right) {
int temp = nums[left];
nums[left] = nums[right];
nums[right] = temp;
}
}
283.移动零
最新推荐文章于 2025-07-23 14:36:54 发布