class Solution {
public:
int findMaxConsecutiveOnes(vector& nums) {
int maxCount=0,count=0;
/
// maxCount is our ans and
//count will increment when we get 1 and we will update maxcount
// and when we get 0 we will make count as 0
//eg. 1 1 0 1 1 1
// in this case at first idx we will increment count
and maxcount same for second idx but at 3rd idx we have
0 so we will make (count=0,maxCount=2)
when we get again 1 and current count
is greater than maxcount we will reassign maxcount=count
/
for(int i=0;i<nums.size();i++){
if(nums[i]==1){
count++;
}else{
count=0;
}
maxCount=max(maxCount,count);
}
return maxCount;
}
};