Optimal freeze window
A build farm repeats the same job calendar every cycle minutes, so minute cycle minus 1 is followed by minute 0 again. Job i is booked at starts[i], a minute in 0 through cycle minus 1, and holds the farm for the minutes starts[i] through ends[i] minus 1 counted around the wrap, so ends[i] is at least starts[i] and never more than starts[i] plus cycle. A job with ends[i] equal to starts[i] holds nothing. The release team must place one freeze of freeze_len consecutive minutes, starting at any minute in 0 through cycle minus 1 and wrapping the same way, with freeze_len at least 1 and at most cycle. A job clashes with the freeze when the two share at least one minute. Return the freeze start clashing with the fewest jobs, breaking ties by the smallest start minute. cycle can be as large as 10^9.
best_freeze_start(starts: list[int], ends: list[int], freeze_len: int, cycle: int) → int[[0,20],[10,30],5,40]out10[[50],[58],4,60]out0[[],[],7,24]out0State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[0,20],[10,30],5,40]10not run yetsample[[50],[58],4,60]0not run yetsample[[],[],7,24]0not run yetsample