leetcode485 python3 88ms 最大连续1的个数

class Solution:
    def findMaxConsecutiveOnes(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        res = 0
        curr = 0
        for i in nums:
            if i != 0:
                curr += 1
            else:
                res = max(res, curr)
                curr = 0
        res = max(res, curr)
        return res
        
posted @ 2018-08-04 23:29  一条图图犬  阅读(249)  评论(0编辑  收藏  举报