python solution


  • 0
    X
    class Solution(object):
        def findMaxConsecutiveOnes(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            tmp,m = 0,0
            for n in nums:
                if n==1:
                    tmp += 1
                else:
                    m = max(m,tmp)
                    tmp=0
            m = max(m,tmp)
            return m
    

Log in to reply
 

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