```
public int findMaxConsecutiveOnes(int[] nums)
{
int q = 0, k = 1, maxCnt = 0, prev = -1, i = 0;
for(i = 0; i < nums.length; i++)
{
if(nums[i] == 1)
continue;
if(k == 1)
{
q = i;
k--;
continue;
}
maxCnt = Math.max(maxCnt, i - 1 - prev);
prev = q;
q = i;
}
return Math.max(maxCnt, i - 1 - prev);
}
```