simple straightforward python code


  • 0
    P
    class Solution(object):
        def findMaxConsecutiveOnes(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            all_pos = []
            ans = 0
            for ii in range(len(nums)):
                if nums[ii] == 1:
                    ans += 1
                    all_pos.append(ans)
                if nums[ii] == 0:
                    all_pos.append(ans)
                    ans = 0
            return max(all_pos)
    

Log in to reply
 

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