My AC C++ clean solution


  • 0
    Y
    class Solution {
    public:
        void moveZeroes(vector<int>& nums) {
            int i=-1, j=0, len = nums.size();
            for(;j<len;j++) 
                if(nums[j]!=0) swap(nums[++i],nums[j]);
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.