Python solution - mark the index of zeros


  • 0
    Q

    """
    class Solution(object):
    def findMaxConsecutiveOnes(self, nums):

        index_zeros = []
        length_ones = []
        
        for i in range(len(nums)):
            if nums[i] == 0:
                index_zeros.append(i)
           
        for i in range(1,len(index_zeros)):
            length_ones.append(index_zeros[i] - index_zeros[i-1])
            
        
        return max(length_ones) - 1
    

    """


Log in to reply
 

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