【leetcode】485. Max Consecutive Ones

problem

485. Max Consecutive Ones

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;

上一篇:Lucene实例教程


下一篇:asp.net mvc 自定义身份验证 2