LeetCode 283 Move Zeroes
#include <vector>
using namespace std;
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int size = nums.size();
int index = 0;
for (int i = 0; i < size; i++){
if (nums[i] != 0){
nums[index++] = nums[i];//先取index再++
}
}
for (int i = index; i < size; i++)
nums[i] = 0;
}
};