Minimum Appointment Cancellations with a Required Break
Reported by candidates from Maven Clinic's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Maven Clinic reported this one in June 2026, and it looks like scheduling trivia until you strip the clinic wrapper. It's classic interval scheduling with a gap added. Pick the most appointments you can keep, cancel the rest, and return the cancelled ones in input order. The HHMM format is the only real trap, because 1459 to 1500 is one minute, not 41. If you've got the OA coming up, learn the greedy and the time conversion and you're mostly done. StealthCoder sits invisibly on your screen as a safety net if your mind goes blank mid-assessment.
The problem
You are given same-day appointments as [startHHMM, endHHMM] pairs and a required nonnegative break in minutes. Two kept appointments are compatible when the later appointment starts at least breakMinutes minutes after the earlier appointment ends. Cancel the minimum number of appointments so that all remaining appointments are compatible. Return the cancelled appointments in their original input order. When several maximum-size compatible schedules exist, keep the schedule produced by considering appointments in increasing end time, then increasing start time, then original input order. Function cancelAppointments(intervals: int[][], breakMinutes: int) → int[][] Examples Example 1 intervals = [[1000,1030],[1005,1010],[1115,1120]] breakMinutes = 5 return = [[1000,1030]] Keeping the appointment ending at 10:10 leaves room for the 11:15 appointment, so only the longer 10:00 appointment is cancelled. Example 2 intervals = [[1400,1459],[1500,1530]] breakMinutes = 5 return = [[1500,1530]] The second appointment starts one minute after the first ends, which is less than the required five-minute break. Example 3 intervals = [[900,930],[935,1000],[1010,1040]] breakMinutes = 5 return = [] Every consecutive gap meets or exceeds five minutes, so nothing is cancelled. Constraints 0 <= intervals.length <= 100000. Every time is a valid same-day 24-hour HHMM value. Each appointment satisfies startHHMM < endHHMM after conversion to minutes. 0 <= breakMinutes <= 1440. No appointment crosses midnight.
Reported by candidates. Source: FastPrep
Pattern and pitfall
It reduces to activity selection. Convert every HHMM to minutes first (hh*60+mm). Sort indices by end time, then start time, then original index. Walk the sorted list and keep an appointment if its start is at least lastKeptEnd + breakMinutes. Otherwise cancel it. The tie-break rule in the prompt matches this exact ordering, so the greedy gives the expected schedule. Initialize lastKeptEnd to negative infinity so the first appointment is always kept. The pitfalls: comparing raw HHMM values, using > instead of >=, and returning cancelled items in sorted order instead of input order. Mark kept indices in a boolean array, then scan the original array and output the unmarked ones. Sorting is O(n log n), fine for 100000 appointments. If the greedy or the conversion slips away from you live, StealthCoder is the hedge that hands you the working code.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Minimum Appointment Cancellations with a Required Break cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Maven Clinic's OA.
Maven Clinic reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Appointment Cancellations with a Required Break FAQ
What's the trick in the Maven Clinic cancellation problem?+
It's interval scheduling. Sort by end time, keep an appointment when its start is at least the last kept end plus the break, cancel otherwise. Convert HHMM to minutes first. The earliest-finishing choice always leaves the most room for later appointments.
How do I handle the HHMM time format?+
Convert each value to minutes with floor(t/100)*60 + t%100 before any comparison. Raw HHMM subtraction breaks across the hour boundary. For example, 1459 to 1500 is a 1-minute gap, not 41. Do the conversion once, up front.
Why does the output order matter here?+
You must return cancelled appointments in their original input order, not sorted order. Sort indices rather than the arrays, record which indices are kept, then loop through the original input and collect the ones not kept.
Is the tie-breaking rule something I need to code separately?+
Just sort by end time, then start time, then original index. That comparator is the tie-break the problem names, and the greedy pass then produces the exact schedule expected. Skipping the index tiebreak can give a different but equally sized answer.
How should I prepare for this in 48 hours?+
Practice activity selection or non-overlapping intervals until the sort-by-end greedy is automatic. Then add the gap condition with >= and test the edge cases: empty input, zero break, and touching intervals. Write it once end to end with index tracking.