python one simple line solution -- just for fun~


  • -1
    S

    return 0 if 1 not in nums else sorted([len(item[1]) for item in [[h, list(g)] for h, g in itertools.groupby(nums)] if item[0] == 1])[-1]


Log in to reply
 

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