loads gives the strain of the workout available on each of a run of consecutive days. Working out on two days in a row is not allowed, and there must be at least count workouts in total.
The *peak* of a plan is the largest load among the chosen days. Return the smallest possible peak over all plans with at least count days in which no two chosen days are consecutive.
It is guaranteed that count non-consecutive days can be chosen.loads=[6, 2, 8, 3, 7], count=2 → 3
Days 1 and 3 (loads 2 and 3) are not adjacent, since day 2 lies between them, so the peak can be just 3.
loads=[4, 1, 5], count=2 → 5
The only two non-adjacent days out of three are 0 and 2, so the peak is max(4, 5) = 5.
loads=[9, 3, 3, 9, 1], count=3 → 9
loads=[6, 2, 8, 3, 7], count=2
3
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.