Magicsheet logo

Reschedule Meetings for Maximum Free Time I

Medium
12.5%
Updated 8/1/2025

Reschedule Meetings for Maximum Free Time I

What is this problem about?

The Reschedule Meetings for Maximum Free Time I interview question gives you a list of non-overlapping meetings (as start/end time pairs) scheduled within a total event duration, and an integer k. You can reschedule at most k meetings by moving them anywhere within the event window (without changing their durations). The goal is to maximize the length of the longest contiguous free time slot after rescheduling.

Why is this asked in interviews?

Meta, Amazon, Google, and Bloomberg ask this problem because it combines greedy reasoning with the sliding window technique applied to gaps between meetings. It models real scheduling optimization problems relevant to calendar applications and resource allocation systems. It tests whether candidates can convert a rescheduling problem into a gap-merging problem by thinking about which meetings to "remove" from the schedule.

Algorithmic pattern used

The pattern is sliding window over meeting gaps. The insight: rescheduling k meetings is equivalent to choosing k meetings to remove from their current positions (creating gaps) and placing them compactly elsewhere. To maximize contiguous free time, find the sliding window of k+1 consecutive gaps (the gaps before, between, and after meetings) that has the maximum total size. Include meeting durations within the window since those meetings can be rescheduled away.

Build an array of gap sizes (including the gaps before the first meeting and after the last), then use a fixed-size window of size k+1 over this gap array.

Example explanation

Event duration: 10. Meetings: [[0,2],[4,6],[8,9]]. k=1.

Gaps: [0 (before meeting 1), 2 (between 1 and 2), 2 (between 2 and 3), 1 (after meeting 3)] = [0, 2, 2, 1]. Meeting durations: [2, 2, 1].

Sliding window of size k+1=2 over gaps + freed meeting durations: consider removing 1 meeting at a time and merging adjacent gaps.

Best: remove middle meeting (duration 2) → merge gaps 2+2+2=6. Maximum free time: 6.

Common mistakes candidates make

  • Not including meeting durations in the window when those meetings can be moved away.
  • Using window size k instead of k+1 (the window spans k+1 gaps when k meetings are removed).
  • Forgetting boundary gaps (before the first meeting and after the last meeting).
  • Not handling the case where k is large enough to remove all meetings.

Interview preparation tip

For the Reschedule Meetings for Maximum Free Time I coding problem, the sliding window and greedy interview pattern is the key. Convert the problem mentally: "removing k meetings" = "merging k+1 consecutive gaps." Build the gap array carefully including boundaries. Google and Bloomberg interviewers appreciate when you articulate the gap-merging insight before writing any code — it shows strong problem reduction skills.

Similar Questions