Move one meeting to another valid time so that the longest continuous free time becomes as large as possible.
You are given a schedule of non-overlapping meetings within a fixed time horizon. You may reschedule at most one meeting to any other position as long as the meetings remain non-overlapping and preserve their durations. Your goal is to maximize the length of the longest continuous free time block in the resulting schedule.
Return the maximum possible length of a free interval after performing at most one rescheduling operation.
The meetings are typically represented as intervals sorted by start time, and the free time is the gaps between adjacent meetings as well as the time before the first meeting and after the last meeting.
Example 1
Input
meetings = [[1,3],[6,7],[9,12]], totalTime = 15
Output
6
Explanation
The free gaps are [0,1], [3,6], [7,9], and [12,15], with lengths 1, 3, 2, and 3. By moving the meeting [6,7] into the gap [12,15], the gap [3,9] becomes continuous free time of length 6.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.