mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-15 05:55:08 +00:00
* Create 14.c * Update README.md * Update leetcode/src/14.c Co-authored-by: David Leal <halfpacho@gmail.com> * Update DIRECTORY.md * Update DIRECTORY.md Co-authored-by: David Leal <halfpacho@gmail.com>
26 lines
448 B
C
26 lines
448 B
C
int findMaxConsecutiveOnes(int* nums, int numsSize){
|
|
int i=0;
|
|
int maxCount=0;
|
|
int count = 0;
|
|
|
|
while(i<numsSize){
|
|
|
|
while(i<numsSize && nums[i]!=0){
|
|
count++;
|
|
i++;
|
|
}
|
|
|
|
if(maxCount<=count){
|
|
maxCount = count;
|
|
}
|
|
|
|
count = 0;
|
|
while(i<numsSize && nums[i]==0){
|
|
i++;
|
|
}
|
|
|
|
}
|
|
return maxCount;
|
|
|
|
}
|