class Solution(object):
def findMaxConsecutiveOnes(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max_count = 0
count = 0
for num in nums:
if num == 1:
count += 1
max_count = max(max_count,count)
else:
count = 0
return max_count
485. Max Consecutive Ones
最新推荐文章于 2024-02-01 04:45:31 发布