Tap here to switch tabs
Problem
Submissions

Problem: Reschedule Meetings for Maximum Free Time II

Reschedule Meetings for Maximum Free Time II lets you move at most one non-overlapping meeting, keeping its duration, to maximize one continuous free interval.

Statement

You are given an integer eventTime representing the total duration of an event on a timeline from 00 to eventTime. You are also given two integer arrays startTime and endTime of length n, representing n meetings where the ithi^{ {th}} meeting takes place during the interval [[startTime[i], endTime[i]]].

All meetings are initially non overlapping and ordered chronologically.

You can reschedule at most 11 meeting by changing its start time to any value tt such that:

  1. The meeting’s duration, endTime[i] −- startTime[i], remains unchanged.

  2. The rescheduled meeting lies completely within the event interval [0,[0, eventTime]].

  3. The rescheduled meeting does not overlap with any of the remaining n−1n - 1 meetings, which stay in their original positions.

Return the maximum continuous free time possible during the event after rescheduling at most 11 meeting.

Note: Continuous free time is any interval of time within [0,[0, eventTime]] where no meeting is taking place.

Constraints:

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

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

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

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reschedule Meetings for Maximum Free Time II

Reschedule Meetings for Maximum Free Time II lets you move at most one non-overlapping meeting, keeping its duration, to maximize one continuous free interval.

Statement

You are given an integer eventTime representing the total duration of an event on a timeline from 00 to eventTime. You are also given two integer arrays startTime and endTime of length n, representing n meetings where the ithi^{ {th}} meeting takes place during the interval [[startTime[i], endTime[i]]].

All meetings are initially non overlapping and ordered chronologically.

You can reschedule at most 11 meeting by changing its start time to any value tt such that:

  1. The meeting’s duration, endTime[i] −- startTime[i], remains unchanged.

  2. The rescheduled meeting lies completely within the event interval [0,[0, eventTime]].

  3. The rescheduled meeting does not overlap with any of the remaining n−1n - 1 meetings, which stay in their original positions.

Return the maximum continuous free time possible during the event after rescheduling at most 11 meeting.

Note: Continuous free time is any interval of time within [0,[0, eventTime]] where no meeting is taking place.

Constraints:

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

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

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

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

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