Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lst = [0, 1, 2, 3, 0, 5, 9, 0, 0, 0, 11, 1, 2, 0, 0, 0, 0, 2, 11, 15, 0, 0, 0, 0, 0, 0]
- # 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
- maxi = 0
- now = 0
- best_ind = -1
- prew_ind = -1
- next_ind = 1
- while next_ind < len(lst):
- if lst[next_ind] == 0:
- now += 1
- next_ind += 1
- else:
- if maxi < now:
- maxi = now
- best_ind = prew_ind
- now = 0
- prew_ind = next_ind
- next_ind += 1
- if next_ind == len(lst):
- maxi = now
- best_ind = prew_ind
- print(maxi, best_ind + 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement