Quite simple C solution


  • 0
    C
    int findMaxConsecutiveOnes(int* nums, int numsSize) {
        int i, count, max;
        
        max = count = 0;
        for (i = 0 ; i < numsSize ; ++i)
            if (nums[i])
                if (++count > max) max = count;            
            else count = 0;
        
        return max;
    }
    

Log in to reply
 

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