Short Python solution

  • 0
    from itertools import groupby
    class Solution(object):
        def findMaxConsecutiveOnes(self, nums):
            :type nums: List[int]
            :rtype: int
            grouped = [list(g) for k, g in groupby(nums) if k == 1]
            return 0 if not grouped else len(max(grouped))

Log in to reply

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