Meeting Rooms II
Reported by candidates from Chainalysis's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Chainalysis OA reported in April 2025 is Meeting Rooms II, and the whole problem hides in one tie. A meeting ending at time 5 and another starting at 5 can share a room. Miss that and you'll overcount by one on Example 3. It's an array problem that rewards sorting plus a sweep or a min-heap. The input can hit 100000 intervals, so brute-force pairwise overlap checks won't survive. If you blank on the tie rule mid-assessment, StealthCoder runs invisibly on your desktop and hands you the working approach. Know the trick first, though. It's short.
The problem
You are given meeting time intervals where each row [start, end] uses a half-open interval: a meeting occupies a room from start up to, but not including, end. Return the minimum number of meeting rooms required so that every meeting can take place. A room whose meeting ends at time t may be reused by another meeting that starts at time t. Function minMeetingRooms(intervals: int[][]) → int Examples Example 1 intervals = [[0,30],[5,10],[15,20]] return = 2 The meeting [0,30] overlaps both shorter meetings, but the two shorter meetings do not overlap each other. Example 2 intervals = [[7,10],[2,4]] return = 1 The meetings are disjoint, so one room can host both. Example 3 intervals = [[1,5],[5,9],[5,6]] return = 2 The room used by [1,5] is available at time 5, while the two meetings beginning at 5 need two rooms together. Constraints 0 <= intervals.length <= 100000. Each interval has exactly two integers [start, end]. 0 <= start < end <= 10^9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to count concurrent meetings. Split intervals into a sorted array of starts and a sorted array of ends. Walk the starts with a pointer on the ends. If the earliest unfinished end is less than or equal to the current start, that room frees up, so advance the end pointer. Otherwise you need a new room. The pitfall is the comparison. Because intervals are half-open, end <= start means reuse, so using strict less-than gives the wrong answer on [[1,5],[5,9],[5,6]]. The alternative is a min-heap of end times: sort by start, pop the heap top when it's <= the new start, push the new end, and track the max heap size. Both run in O(n log n). Handle the empty input and return 0. If the tie logic slips under pressure, StealthCoder is the hedge during the live OA, but the rule itself is one character: <=.
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 Chainalysis's OA.
Chainalysis 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 in Meeting Rooms II?+
Track how many meetings overlap at once. Sort starts and ends separately, then sweep. When the earliest end is at or before the current start, reuse that room. Otherwise add a room. The answer is the peak count of simultaneous meetings.
How do I handle meetings that end exactly when another starts?+
The problem says the interval is half-open, so a meeting ending at t frees its room for one starting at t. Use end <= start as the reuse condition. With strict less-than you'd return 3 instead of 2 on [[1,5],[5,9],[5,6]].
Should I use a heap or the two-array sweep?+
Either works at O(n log n). The two sorted arrays are shorter to write and have fewer bugs. The heap is more intuitive if you think in terms of rooms. Pick whichever you can type without hesitating, since 100000 intervals rules out O(n^2).
What edge cases should I test for the Chainalysis version?+
Test an empty list, which should return 0. Test a single meeting, which returns 1. Test back-to-back meetings like [[1,5],[5,9]], which need one room. Test several meetings starting at the same time. Test a big meeting that covers all others.
How do I prepare for this in 48 hours?+
Write the sort-and-sweep version from scratch twice, then the heap version once. Run all three examples by hand, especially Example 3. Then try the same idea on a related interval problem. You're drilling one tie rule and one sweep, not a whole topic.