One year ago failed on this...


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

Log in to reply
 

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