public class _283移动零_hot {
public void moveZeroes(int[] nums) {
if (nums == null) {
return;
}
int j = 0;
for (int i = 0; i < nums.length; i++) {
if (nums[i] != 0) {
int tmp = nums[i];
nums[i] = nums[j];
nums[j++] = tmp;
}
}
}
}```
双指针算法:移动零
最新推荐文章于 2024-09-11 00:16:09 发布