max_count
to 0 to keep track of the maximum number of consecutive 1
s.current_count
to 0 to keep track of the current number of consecutive 1
s.nums
.
a. If the current element is 1
, increment current_count
by 1.
b. If the current element is 0
, compare current_count
with max_count
and update max_count
if necessary. Then reset current_count
to 0.current_count
with max_count
one last time to account for a sequence that might end at the last element.max_count
as the result.