Max Consecutive Ones

来源:互联网 发布:春城影院软件 编辑:程序博客网 时间:2024/05/24 05:57

找出1的最大连续个数

class Solution(object):

    def findMaxConsecutiveOnes(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        res=0
        step=0
        for i in nums:
            if i==1:
                step+=1
                res=max(res,step)
            else:
                step=0
        return res
原创粉丝点击