Python solution


  • 0
    H
    class Solution(object):
        def findMaxConsecutiveOnes(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            result = dict()
            i = 0
            result[i] = 0
            for item in nums:
                if item == 0:
                    i += 1
                    result[i] = 0
                else:
                    result[i] += 1
            return max(result.values())
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.