https://leetcode-cn.com/problems/move-zeroes/
双指针
//双指针// 两个原则// 1) i位置是0, i++// 2) i位置不是0. i位置跟to的下一个数交换, i++, to++public void moveZeroes(int[] nums) {int to = -1;for (int i = 0; i < nums.length; i++) {if (nums[i] != 0) {swap(i, ++to, nums);}}}private void swap(int i, int j, int[] nums) {int tmp = nums[i];nums[i] = nums[j];nums[j] = tmp;}
