最大連續1的個數

題目簡單:

class Solution:
    def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
        lens = len(nums)
        maxCount = 0
        Count = 0
        for i in nums:
            if i == 1:
                Count += 1
                if Count > maxCount:
                    maxCount = Count
            else:
                Count = 0
                    
        return maxCount

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章