llllmz

导航

485. 最大连续 1 的个数c

int findMaxConsecutiveOnes(int* nums, int numsSize) {
    int max=0,index=0,count=0;
    while(index<numsSize){
        if(nums[index]==1){
            count++;
            if(count>max) max=count;
        }else{
            count=0;
        }
        index++;
    }
    return max;
}

 

posted on 2024-03-20 17:08  神奇的萝卜丝  阅读(10)  评论(0)    收藏  举报