Meeting Room Scheduler
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on Amazon's Meeting Room Scheduler is scanning every room for every request. With 10^5 rooms and 10^5 meetings, that's a timeout waiting to happen. This one was reported in September 2026, and it's a queue-style problem that really wants two heaps. Requests come in sorted by start, rooms are half-open intervals, and a rejected request reserves nothing. If you blank during the live assessment, StealthCoder runs invisibly on your desktop and gives you the solution in real time. Know the shape before you sit down, though.
The problem
Implement a scheduler for roomCount meeting rooms numbered from 0 to roomCount - 1. Each row meetings[i] = [start, end] is a request for the half-open interval [start, end). Requests appear in nondecreasing start order and are processed in input order. Assign the lowest-numbered available room. If every room overlaps the request, reject it with -1. Return an array whose ith value is the assigned room number or -1. A rejected request does not reserve a room. Function scheduleMeetings(roomCount: int, meetings: int[][]) → int[] Examples Example 1 roomCount = 2 meetings = [[0,10],[5,7],[10,12],[10,15]] return = [0,1,0,1] The first two requests occupy rooms 0 and 1. At time 10, both are free; input order gives the third request room 0 and the fourth room 1. Example 2 roomCount = 1 meetings = [[1,4],[2,3],[4,5]] return = [0,-1,0] The second request conflicts with [1,4). The room is available again exactly at time 4. Example 3 roomCount = 2 meetings = [[1,2],[1,2],[1,2]] return = [0,1,-1] Two simultaneous requests take both rooms, so the third request is rejected. Constraints 1 <= roomCount <= 10^5. 1 <= meetings.length <= 10^5. meetings[i].length == 2. 0 <= start < end <= 10^9. Meeting start times are nondecreasing.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is two min-heaps. One holds free room numbers, so the top is always the lowest available room. The other holds busy rooms as (endTime, room) pairs. For each request, pop every busy entry with end <= start and push its room back into the free heap. The half-open interval is why it's <= and not <. Example 2 shows this: a room frees exactly at time 4. Then, if the free heap is empty, answer -1 and change nothing. Otherwise pop the smallest room, record it, and push (end, room) onto the busy heap. Common pitfalls: using < instead of <=, reserving a room for a rejected request, and linear scans over rooms. Start times are nondecreasing, so you never need to sort or rewind. Total cost is O((n + m) log n). If the heap bookkeeping slips under pressure, StealthCoder is the hedge during the live OA.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Meeting Room Scheduler 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Meeting Room Scheduler FAQ
What's the trick in Amazon's Meeting Room Scheduler?+
Use two heaps. A min-heap of free room numbers gives the lowest available room instantly. A min-heap of (endTime, room) tracks busy rooms. Before each request, release every room whose end time is at most the new start. That keeps each request at O(log n).
Why does the half-open interval matter?+
Meetings are [start, end), so a room ending at 10 is free for a meeting starting at 10. Examples 1 and 2 both depend on it. Release rooms when end <= start. Using strict less-than gives wrong answers on exactly those boundary cases.
Can I just loop over all rooms for each meeting?+
Not safely. With up to 10^5 rooms and 10^5 meetings, a nested loop is around 10^10 operations. It passes small examples and fails the larger hidden tests. Heaps bring it down to roughly (n + m) log n.
Does a rejected request block a room?+
No. The problem says a rejected request does not reserve a room. When the free heap is empty, append -1 and move on without touching either heap. Example 3 shows it: the third identical request gets -1 and nothing changes.
How do I prepare for this in 48 hours?+
Code the two-heap version from scratch twice. Then trace Examples 1 through 3 by hand, paying attention to the release step at time 10 and time 4. Practice your language's heap API, since tuple ordering and min-heap defaults cause most bugs. This pattern recurs in scheduling questions.