Skip to content

Commit 21ac9c7

Browse files
Update Max Consecutive Ones III - Leetcode 1004.py
Use if statement instead of while to get back one zero to find the next maximum consecutive subsequence of 1.
1 parent b161479 commit 21ac9c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Max Consecutive Ones III - Leetcode 1004.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def longestOnes(self, nums: List[int], k: int) -> int:
99
if nums[r] == 0:
1010
num_zeros += 1
1111

12-
while num_zeros > k:
12+
if num_zeros > k:
1313
if nums[l] == 0:
1414
num_zeros -= 1
1515
l += 1

0 commit comments

Comments
 (0)