Is there any questions about my codes of moveZeroes?


  • 0
    A
     void moveZeroes(int* nums, int numsSize)
    {
            int i, j;
            int temp;
            
            for(i = 0, j = i+1; i < numsSize; i++)
            {
                if(nums[i] == 0)
                {
                    while(nums[j] == 0)
                    {
                    	j++;
        				if(j >= numsSize)
        					break; 
                    }
                    temp = nums[j];
                    nums[j] = nums[i];
                    nums[i] = temp;
                    j++; 
        			if(j >= numsSize)
        				break;    
                }
            }
        }
    

    My codes is correct in Dev-C++. But when I submit it to the system of leetCode, why it is wrong?


Log in to reply
 

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