Skip to content

Commit 661a67a

Browse files
authored
Create Solution.java
1 parent ab4a215 commit 661a67a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int longestOnes(int[] A, int K) {
3+
int l = 0, r = 0;
4+
while (r < A.length) {
5+
if (A[r++] == 0) --K;
6+
if (K < 0 && A[l++] == 0) ++K;
7+
}
8+
return r - l;
9+
}
10+
}

0 commit comments

Comments
 (0)