Same as removing all the same val in a array


  • 0
    N
    void moveZeroes(int *nums,int numsSize) {
    	int lop = 0,index_after = 0;
    	while(lop < numsSize ) {
    		if(nums[lop] != 0) {
    			nums[index_after++] = nums[lop];
    		}
    		lop++;
    	}
    	while(index_after < numsSize) {
    		nums[index_after++] = 0;
    	}
    }
    

    `

    8 ms


Log in to reply
 

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