Max Consecutive Ones

xiaoxiao2021-02-27  186

找出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
转载请注明原文地址: https://www.6miu.com/read-12545.html

最新回复(0)