class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { int count=0; int max=count; for(int i=0;i<nums.size();i++){ if(nums[i]==1) count++; if(count>max) max = count; if(nums[i]!=1) count=0; } return max; } };
2023-11-09 14:48:10
class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { int count=0; int max=count; for(int i=0;i<nums.size();i++){ if(nums[i]==1) count++; if(count>max) max = count; if(nums[i]!=1) count=0; } return max; } };