```
public int findMaxConsecutiveOnes(int[] nums) {
int k = 1;//you can change k times
int l = 0, r = 0;
int zeroCount = 0;
int max = 0;
while(r < nums.length){
if(zeroCount <= k){
if(nums[r] == 0)
zeroCount++;
r ++;
}
if(zeroCount > k){
if(nums[l] == 0){
zeroCount--;
}
l ++;
}
if(r-l > max){
max = r-l;
}
}
return max;
}
```