mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-25 23:09:36 +03:00
25f3b63d5b
* Create 485.c added "485. Max Consecutive Ones" solution * Update README.md Co-authored-by: David Leal <halfpacho@gmail.com>
24 lines
329 B
C
24 lines
329 B
C
int max(a,b){
|
|
if(a>b)
|
|
return a;
|
|
else
|
|
return b;
|
|
}
|
|
|
|
int findMaxConsecutiveOnes(int* nums, int numsSize){
|
|
int count = 0;
|
|
int result = 0;
|
|
|
|
for (int i = 0; i < numsSize; i++)
|
|
{
|
|
if (nums[i] == 0)
|
|
count = 0;
|
|
else
|
|
{
|
|
count++;
|
|
result = max(result, count);
|
|
}
|
|
}
|
|
return result;
|
|
}
|