1004. 最大连续1的个数 III
public class Solution {
public int LongestOnes(int[] A, int K) {
int max = 0;
int zero = 0;
int from = 0, to = 0;
while (to < A.Length)
{
if (A[to] == 0)
{
zero++;
while (zero > K)
{
if (A[from] == 0)
{
zero--;
}
from++;
}
}
to++;
if (to - from > max)
{
max = to - from;
}
}
return max;
}
}