[LeetCode]最大连续1的个数
题目
代码
class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int length=0;
int maxLength=0;
for(int i=0;i<nums.size();i++)
{
if(nums[i]==0)
length=0;
else
length++;
if(length>maxLength)
maxLength=length;
}
return maxLength;
}
};
https://github.com/li-zheng-hao