"find the length of the maximum runs/groups of ones in a list"
Groups means check groupby for me and I came up with the following
from itertools import groupby
def answer(lst):
return len(max(tuple(g) for k, g in groupby(lst)
if k == 1))
print(answer([1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0]))
Which returns 3.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
"find the length of the maximum runs/groups of ones in a list"
Groups means check groupby for me and I came up with the following
Which returns 3.