problem
solution1:
class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
if(nums.empty()) return ;
int ans = , max = INT_MIN;
for(int i=; i<nums.size(); i++)
{
if(nums[i]==) ans++;
else if(nums[i]!=)
{
if(max<ans) max = ans;
ans = ;
}
}
return max>ans ? max : ans;
}
};
参考
1. Leetcode_485. Max Consecutive Ones;
完