1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| class Solution(object): def findMaxConsecutiveOnes(self, nums): """ :type nums: List[int] :rtype: int """ count = 0 maxcount = 0 for num in nums: if num == 0: maxcount = max(maxcount, count) count = 0 else: count += 1 return max(maxcount,count)
|