# Move Zeroes

public class Solution {
public void moveZeroes(int[] nums) {

int p0 = 0, p1 = 0;
while (p0 < nums.length && p1 < nums.length) {
if (nums[p0] != 0) {
p0++;
continue;
}
if (nums[p1] == 0) {
p1++;
continue;
}
// while (nums[p0] != 0) {
//     p0++;
//     if (p0 >= nums.length) {
//         return;
//     }
// }
// while (nums[p1] == 0) {
//     p1++;
//     if (p1 >= nums.length) {
//         return;
//     }
// }
if (p0 < p1) {
int temp = nums[p0];
nums[p0] = nums[p1];
nums[p1] = temp;
p0++;
p1++;
} else {
p1++;
}
}

//// right ////
// for (int i = nums.length - 1; i >= 0; i--) {
//     for (int j = 0; j < i; j++) {
//         if (nums[j] == 0) {
//             int temp = nums[j + 1];
//             nums[j + 1] = nums[j];
//             nums[j] = temp;
//         }
//     }
// }
}
}

#### 283. Move Zeroes [easy] (Python)

2016-05-12 15:29:07

#### leetcode 283: Move Zeroes

2015-09-19 13:32:31

#### leetcode：283. Move Zeroes（Java）解答

2016-01-10 21:05:39

#### leetcode【283 Move Zeros】【python】

2016-09-01 21:55:22

#### [leetcode-283]Move Zeroes(java)

2015-09-24 20:57:26

#### 景岁的Leetcode解题报告：283. Move Zeroes(Python)

2016-01-29 15:46:16

#### [283] Move Zeroes

2016-07-20 19:47:02

#### 283.MoveZeroes

2018-01-10 17:15:23

#### 283. Move Zeroes

2015-11-27 22:22:10

#### [LeetCode] Move Zeroes - 整数数组处理问题

2015-09-20 20:11:11