0 to time day_end. It holds n non-overlapping meetings sorted by time: meeting i takes the interval [starts[i], ends[i]].
You may move **at most one** meeting to any other time. The moved meeting keeps its duration, stays within the workday and must not overlap the others. It does not have to keep its place in the order: it can land before or after any other meeting.
Return the longest possible stretch of continuous free time within the day.day_end=12, starts=[0, 3, 10], ends=[2, 4, 11] → 8
Move the meeting [3, 4] to the very end of the day, [11, 12]. Then nothing happens from 2 to 10, a break of length 8.
day_end=9, starts=[1, 4], ends=[3, 8] → 2
Each free piece is 1 unit long and no meeting fits into a gap elsewhere. All you can do is slide a meeting to merge its two neighbouring gaps: for example, [1, 3] → [0, 2] frees [2, 4].
day_end=3, starts=[0, 1], ends=[1, 3] → 0
The meetings fill the whole day, so there is no free time at all.
day_end ≤ 10⁹len(starts) = len(ends) ≤ 10⁵starts[i] < ends[i] ≤ day_endends[i] ≤ starts[i + 1]day_end=12, starts=[0, 3, 10], ends=[2, 4, 11]
8
Run checks the first 3 tests in your browser. Submit checks all 113 tests on the server, hidden ones included.