标签:target color -o public leetcode problem max com solution
problem
solution1:
class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { if(nums.empty()) return 0; int ans = 0, max = INT_MIN; for(int i=0; i<nums.size(); i++) { if(nums[i]==1) ans++; else if(nums[i]!=1) { if(max<ans) max = ans; ans = 0; } } return max>ans ? max : ans; } };
参考
1. Leetcode_485. Max Consecutive Ones;
完
【leetcode】485. Max Consecutive Ones
标签:target color -o public leetcode problem max com solution
原文地址:https://www.cnblogs.com/happyamyhope/p/10623091.html