File tree 2 files changed +7
-5
lines changed
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -16,16 +16,17 @@ var longestSubarray = function (nums) {
16
16
17
17
if ( k < 0 ) {
18
18
console . log ( `~> k: ${ k } ` )
19
- // l++;
20
- while ( l < r ) {
19
+
20
+ while ( k < 0 ) {
21
21
if ( nums [ l ] === 0 ) {
22
22
l ++ ;
23
+ k ++ ;
23
24
break ;
24
25
}
25
26
26
27
l ++ ;
27
28
}
28
- k ++ ;
29
+
29
30
tmpMax = r - l + 1
30
31
console . log ( `~> new l: ${ l } , new tmpMax: ${ tmpMax } ` )
31
32
}
@@ -34,6 +35,7 @@ var longestSubarray = function (nums) {
34
35
max = Math . max ( max , tmpMax )
35
36
r ++ ;
36
37
}
38
+
37
39
console . log ( `~> k: ${ k } ` )
38
40
39
41
return max - DELETE_COUNT ;
Original file line number Diff line number Diff line change @@ -14,16 +14,16 @@ var longestSubarray = function (nums) {
14
14
15
15
if ( k < 0 ) {
16
16
17
- while ( l < r ) {
17
+ while ( k < 0 ) {
18
18
if ( nums [ l ] === 0 ) {
19
19
l ++ ;
20
+ k ++ ;
20
21
break ;
21
22
}
22
23
23
24
l ++ ;
24
25
}
25
26
26
- k ++ ;
27
27
tmpMax = r - l + 1
28
28
}
29
29
}
You can’t perform that action at this time.
0 commit comments