python itertools solution


  • 0
    A
    class Solution(object):
        def findMaxConsecutiveOnes(self, nums):
            counter = [len(list(g)) for k, g in itertools.groupby(nums) if k == 1]
            
            return max(counter) if counter else 0
    

Log in to reply
 

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