Meeting Rooms II
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
With up to 10^4 intervals, comparing every meeting against every other one gets ugly fast, and that's the trap in the Amazon Meeting Rooms II question reported in September 2026. You need the minimum number of rooms so no overlapping meetings share one. The pattern is sorting plus a sweep, with a min-heap as the common variant. It's a classic, so you've probably seen it. If your mind goes blank mid-assessment, StealthCoder runs invisibly on your desktop and can hand you the solution while the proctor sees nothing. Know the trick first and you won't need it.
The problem
Given an array of meeting time intervals intervals, where intervals[i] = [start_i, end_i], return the minimum number of conference rooms required. Function minMeetingRooms(intervals: int[][]) → int Examples Example 1 intervals = [[0,30],[5,10],[15,20]] return = 2 Example 2 intervals = [[7,10],[2,4]] return = 1 Constraints 1 <= intervals.length <= 10^4 0 <= start_i < end_i <= 10^6
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: you only care about how many meetings are active at once. Sort the start times and end times into two separate arrays. Walk through the starts with a pointer into the ends. If the next start is before the earliest unfinished end, you need a new room. Otherwise a room frees up, so advance the end pointer. The max concurrent count is your answer. The heap version sorts by start and keeps a min-heap of end times. Pop if the earliest end is less than or equal to the new start, then push the new end. Heap size at the end is the answer. The common pitfall is the boundary: a meeting ending at 10 and one starting at 10 don't overlap, so use <= when freeing a room. Another miss is forgetting to sort first. Both run in O(n log n). If you freeze during the live OA, StealthCoder is the safety net that surfaces this approach.
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 Rooms II 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
This OA pattern shows up on LeetCode as meeting rooms ii. If you have time before the OA, drill that.
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 Rooms II FAQ
What's the trick for Meeting Rooms II?+
Track concurrent meetings, not pairs. Sort starts and ends separately, then sweep. Each start that happens before the earliest remaining end needs a new room. Otherwise reuse one. The peak count is the answer. A min-heap of end times does the same job and is easier to explain out loud.
Why does brute force fail here?+
With intervals.length up to 10^4, checking every pair is about 10^8 comparisons, and assigning rooms greedily without ordering still gets messy. Sorting gets you O(n log n), which is about 10^4 times 14 operations. That's the whole reason the constraint is there.
Should I use a heap or the two-array sweep?+
Either passes. The heap is more intuitive: sort by start, pop the earliest end if it's done, push the new end. The two-array sweep is shorter and uses no extra data structure. Pick the one you can write without bugs under pressure.
What edge case trips people up on this one?+
Touching intervals. [2,4] and [4,6] don't overlap, so one room is enough. That means freeing a room when the earliest end is less than or equal to the next start. Using strict less-than gives you an extra room and a wrong answer on tight tests.
How do I prepare for this in 48 hours?+
Write the heap version from scratch twice, then the two-array sweep once. Run Example 1, which should return 2, and Example 2, which should return 1. Then do a couple of related interval problems like merge intervals. The pattern repeats, so the muscle memory carries over.