Python O(n) code


  • 0
    D

    """class Solution(object):
    def findMaxConsecutiveOnes(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    Count=0
    globalCount=0
    for number in nums:
    if number == 1:
    Count+=1
    else:
    Count=0
    globalCount=max(Count,globalCount)
    return globalCount"""


Log in to reply
 

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