485. Max Consecutive Ones
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
left = 0
right = 0
ans = 0
while right < len(nums):
num = nums[right]
right += 1
if num == 1:
ans = max(ans, right - left)
else:
left = right
return ansLast updated