Skip to content

Commit

Permalink
Status:solved
Browse files Browse the repository at this point in the history
  • Loading branch information
Sundar2k4 committed Aug 8, 2024
1 parent f29f7eb commit 7a9901d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions consequetiveones.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Solution
{
public:
int findMaxConsecutiveOnes(vector<int> &nums)
{
int n = nums.size();
int count = 0;
int countval = 0;
for (int i = 0; i < n; i++)
{
if (nums[i] == 1)
{
count++;
}
else
{
if (count > countval)
{
countval = count;
}
count = 0;
}
}
if (count > countval)
{
countval = count;
}

return countval;
}
};

0 comments on commit 7a9901d

Please sign in to comment.