class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int i,flag=0,maxCount=0;
for(i=0;i<nums.size();i++)
{
if(nums[i]!=1)
{
flag=0;
}
else
{
flag++;
}
if(flag&&flag>maxCount)
maxCount=flag;
}
return maxCount;
}
};
10-25
2888
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)