Circular shift coverage

Write codeHard38 min

Your task

An operations team staffs a rota for a single day of 1440 minutes, numbered 0 through 1439, and the day wraps, so minute 1439 is followed by minute 0. alert_minutes lists the minute of every page from a typical day, in no particular order and possibly with repeats. The team can schedule shifts shifts, all of the same span, each free to start at any minute and each covering a contiguous stretch of the clock. A shift of span s starting at minute m covers minute m through minute m plus s, counted around the wrap. Return the smallest span that lets those shifts cover every alerting minute. Return 0 when there are no alerts, and -1 when there are alerts but no shifts.

Examples

shortest_shift_span(alert_minutes: list[int], shifts: int) -> int
Example 1
Inputshortest_shift_span([0, 10, 20, 31], 2)
Output11
Example 2
Inputshortest_shift_span([1430, 1435, 5, 10], 1)
Output20
Example 3
Inputshortest_shift_span([], 3)
Output0