Tap here to switch tabs
Problem
Submissions

Problem: Reschedule Meetings for Maximum Free Time I

med
30 min
Try to solve the Reschedule Meetings for Maximum Free Time I problem.

Statement

You are given an event that runs from time 00 to time eventTime. There are n non overlapping meetings scheduled during the event, where the ith meeting occupies the half open interval [startTime[i], endTime[i]).

You may reschedule at most k meetings. Rescheduling a meeting means choosing a new half open interval of the same duration that lies entirely within [0,[0, eventTime ]] and does not overlap any other meeting after all reschedules are applied.

Return the maximum possible length of a continuous time interval during the event that contains no meetings.

Note: Meetings are given in non overlapping order, meaning each meeting ends no later than the next meeting starts.

Constraints:

  • 1≤1 \leq eventTime ≤109\leq 10^9

  • n ==== startTime.length ==== endTime.length

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq n

  • 0≤0 \leq startTime[i] << endTime[i] ≤\leq eventTime

  • endTime[i] ≤\leq startTime[i + 1] where i lies in the range [0,[0, n −2]- 2]

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reschedule Meetings for Maximum Free Time I

med
30 min
Try to solve the Reschedule Meetings for Maximum Free Time I problem.

Statement

You are given an event that runs from time 00 to time eventTime. There are n non overlapping meetings scheduled during the event, where the ith meeting occupies the half open interval [startTime[i], endTime[i]).

You may reschedule at most k meetings. Rescheduling a meeting means choosing a new half open interval of the same duration that lies entirely within [0,[0, eventTime ]] and does not overlap any other meeting after all reschedules are applied.

Return the maximum possible length of a continuous time interval during the event that contains no meetings.

Note: Meetings are given in non overlapping order, meaning each meeting ends no later than the next meeting starts.

Constraints:

  • 1≤1 \leq eventTime ≤109\leq 10^9

  • n ==== startTime.length ==== endTime.length

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq n

  • 0≤0 \leq startTime[i] << endTime[i] ≤\leq eventTime

  • endTime[i] ≤\leq startTime[i + 1] where i lies in the range [0,[0, n −2]- 2]