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>
This commit is contained in:
Aniket Dubey 2022-11-09 02:38:46 +05:30 committed by GitHub
parent a0f658311d
commit 25f3b63d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -72,6 +72,7 @@
| 442 | [Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array/) | [C](./src/442.c) | Medium | | 442 | [Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array/) | [C](./src/442.c) | Medium |
| 461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance/) | [C](./src/461.c) | Easy | | 461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance/) | [C](./src/461.c) | Easy |
| 476 | [Number Complement](https://leetcode.com/problems/number-complement/) | [C](./src/476.c) | Easy | | 476 | [Number Complement](https://leetcode.com/problems/number-complement/) | [C](./src/476.c) | Easy |
| 485 | [Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones/) | [C](./src/485.c) | Easy |
| 509 | [Fibonacci Number](https://leetcode.com/problems/fibonacci-number/) | [C](./src/509.c) | Easy | | 509 | [Fibonacci Number](https://leetcode.com/problems/fibonacci-number/) | [C](./src/509.c) | Easy |
| 520 | [Detect Capital](https://leetcode.com/problems/detect-capital/) | [C](./src/520.c) | Easy | | 520 | [Detect Capital](https://leetcode.com/problems/detect-capital/) | [C](./src/520.c) | Easy |
| 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i/) | [C](./src/561.c) | Easy | | 561 | [Array Partition I](https://leetcode.com/problems/array-partition-i/) | [C](./src/561.c) | Easy |

23
leetcode/src/485.c Normal file
View File

@ -0,0 +1,23 @@
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;
}