50 cases Time limit 1000 ms total Memory 256 MB
People stand in a line, and each one knows a rumour worth some number of points. Every round, everyone talks to the people directly next to them, and at the same moment they all switch to the juiciest rumour they've heard: the largest of their own number and their neighbours' numbers.
Return how many rounds it takes until everyone knows the same rumour.
Constraints:
len(l) ≤ 12Examples:
f([1, 5, 2, 2, 2]) returns 3
f([3, 3]) returns 0 (they already agree)
f([0, 9, 0, 0, 0, 9]) returns 2
[[1, 5, 2, 2, 2]]
3
[[3, 3]]
0
[[0, 9, 0, 0, 0, 9]]
2