```
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int maxnum=0;
int count=0;
int j=0;
for(int i=0;i<nums.size();i++)
{
if(nums[i]!=1){
count=i-j;
j=i+1;
if(count>maxnum) maxnum=count;
}
if(i==nums.size()-1&&nums[i]==1){
count=i-j+1;
if(count>maxnum) maxnum=count;
}
}
```

```
return maxnum;
}
```

};