Python solution


  • 0
    V

    class Solution(object):
    def findMaxConsecutiveOnes(self,nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    count = 0
    maxcon = []
    for i in range(len(nums)):
    if nums[i] == 1:
    count += 1
    elif nums[i] == 0:
    maxcon.append(count)
    count=0
    maxcon.append(count)
    return max(maxcon)


Log in to reply
 

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