https://leetcode-cn.com/problems/move-zeroes/
/*
双指针
左指针 已经处理好的
右指针 待处理的
*/
public void moveZeroes(int[] nums) {
int length = nums.length;
int left = 0;
int right = 0;
while (right < length) {
if (nums[right] != 0) {
swap(nums, left, right);
left++;
}
right++;
}
}
private void swap(int[] nums, int left, int right) {
int tmp = nums[left];
nums[left] = nums[right];
nums[right] = tmp;
}