A c code I don't know why it can not access 10000 test case


  • 0
    S

    int findMaxConsecutiveOnes(int* nums, int numsSize)
    {

       int i;
       int count1 = 0;
       int count2 = 0;
       int flag = 0;
       printf("*******\n");
       printf("%d\n", numsSize);
       for(i=0;i<numsSize;i++)
       {
            if(nums[i]==1)
            {
                count1++;
            }
            else
            {
                if(count1>count2)
                {
                    count2 = count1;
                    count1 = 0;
                }
            }
       }
       return count2>count1?count2:count1;
    

    }


Log in to reply
 

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