class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int max_cnt = 0;
int cnt = 0;
for (int i = 0; i < nums.size(); i++)
{
if (nums[i] != 1)
{
cnt = 0;
}
else
{
cnt++;
max_cnt = max(max_cnt, cnt);
}
}
return max_cnt;
}
};
12-26
562
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-01
249
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-21
753
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)