My c solution in different style


  • 5
    N
    void moveZeroes(int* nums, int numsSize) {
        for(int i = 0, j = 0; i < numsSize; i++) {
            if(nums[j]) {
                j++;
            } else if (nums[i] != 0) {
                nums[j] = nums[i];
                nums[i] = 0;
                j++;
            }
        }
    }

Log in to reply
 

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