Reschedule k Meetings to Find Maximum Break Time
Updated
Problem statement
For example, there are n = 4 presenters scheduled for the course of the event which begins at time 0 and ends at time t = 15. The meetings start at times start = [4, 6, 7, 10] and end at times finish = [5, 7, 8, 11]. You can rearrange up to k = 2 meetings. In this case, we have 4 periods without speakers scheduled: [0-3], [5], [8-9], [11-14]. The meeting ends after hour 14. If the first meeting is shifted to an hour later, a break is created from 0 to 5 (5 hours). If the last speech is moved up to 8, it will end at 9, leaving a break from 9 to 15. There is no point in moving the middle two speeches in this case. The longest break that can be achieved is 15 - 9 = 6 hours by moving the last speech two hours earlier.
Function
findMaximumBreakTime(start: int[], finish: int[], t: int, k: int) → int
Complete the function findMaximumBreakTime in the editor.
findMaximumBreakTime has the following parameters:
- 1.
int[] start: an array of integers representing the start times of meetings - 2.
int[] finish: an array of integers representing the end times of meetings - 3.
int t: the total duration of the day - 4.
int k: the number of meetings that can be rescheduled
Returns
int: the maximum break time that can be achieved by rescheduling up to k meetings
Examples
Example 1
start = [4, 6, 7, 10]finish = [5, 7, 8, 11]t = 15k = 2return = 6
The longest break that can be achieved is 15 - 9 = 6 hours by moving the last speech two hours earlier.
Constraints
- 1≤n≤10^5 (number of events)
- 0≤k≤n (number of reschedules allowed)
- 1≤t≤10^9 (total duration of the day)
- 0≤start[i]
More Google Phone Screen questions
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
- Minimum Total Layover WaitPHONE SCREEN · Seen Nov 2026
- Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Minimum Removals for Non-Overlapping IntervalsByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREENMaven Clinic interview questions
- Minimum Arrows to Burst BalloonsAdobe · PHONE SCREENAdobe interview questions
- Minimum Meeting RoomsSentry · PHONE SCREENSentry interview questions
- Minimum RetailersAmazon · OA
- Maximum Compatible Time WindowsIBM · OAIBM interview questions
- Minimum Railway PlatformsMakeMyTrip.com · ONSITE INTERVIEWMakeMyTrip.com interview questions
- Task SchedulingJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximum Non-Overlapping IntervalsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
Google interview experiences
- Google L4 SWE Phone Screen: 1 Experience
- Google ML Engineering Manager Onsite: 1 Experience
- Google Experienced SWE First Round and Onsite: 1 Experience
- Google AI Coding Interview and AI OA: 2 Experiences
- Google SWE Intern Interview Results Timeline: 13 Experiences
- Google L4 SWE Phone Screen and Kirkland Onsite: 1 Experience