TheAlgorithms-C/leetcode/src/485.c
Aniket Dubey 25f3b63d5b
chore: add LeetCode problem 485 (#981)
* Create 485.c

added "485. Max Consecutive Ones" solution

* Update README.md

Co-authored-by: David Leal <halfpacho@gmail.com>
2022-11-08 15:08:46 -06:00

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;
}