// Comment int longestOnes(int* A, int ASize, int K) { int result = 0; int localmax = 0; int indexOfZero = 0; for(int i = 0; i < ASize; ++i){ if(A[i] == 0) K--; localmax++; while(K<0){ if(A[indexOfZero] == 0){ K++; } indexOfZero++; localmax--; } result = localmax > result ? localmax : result; } return result; }
沒有留言:
張貼留言