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

Posted 一条图图犬

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
        

以上是关于leetcode485 python3 88ms 最大连续1的个数的主要内容,如果未能解决你的问题,请参考以下文章