Max Consecutive Ones
Input: [1,1,0,1,1,1]
Output: 3class Solution(object):
def findMaxConsecutiveOnes(self, nums):
count = 0
ans = 0
for num in nums:
if num == 1:
count += 1
ans = max(ans, count )
else:
cnt = 0
return ansLast updated