码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-08-05 00:40:35      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:python   self   type   dma   最大连续   def   最大   int   nes   

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的个数

标签:python   self   type   dma   最大连续   def   最大   int   nes   

原文地址:https://www.cnblogs.com/theodoric008/p/9420613.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!