0
点赞
收藏
分享

微信扫一扫

70-Array--LC485最大连续1的个数

朱小落 2022-03-16 阅读 40

在这里插入图片描述

class Solution(object):
    def findMaxConsecutiveOnes(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        count = result = 0
        for i in nums:
            if i == 1:
                count += 1
            else:
                result = max(result, count)
                count = 0
        return max(result, count)
举报

相关推荐

0 条评论