力扣:数组与矩阵 485. 最大连续1的个数
作者:互联网
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;
}
};
标签:findMaxConsecutiveOnes,nums,int,矩阵,Solution,力扣,flag,maxCount,485 来源: https://blog.csdn.net/weixin_44864471/article/details/110880059