s4553711
7/6/2017 - 2:08 PM

283.cpp

class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int index = 0;
        for(int i = 0; i < nums.size(); i++) {
            int tmp = nums[i];
            if (tmp != 0) {
                nums[index++] = tmp;
            }
        }
        for(index; index < nums.size(); index++) {
            nums[index] = 0;
        }
    }
};