mediumCodingEntryMidSenior
Given a list of meetings with start and end times, tell me the minimum number of rooms needed to hold all of them.
5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup
Answer
Short answer
The minimum room count is the maximum number of meetings running at once, found by sweeping the start and end times in sorted order and tracking a running count. The starts and ends can be sorted independently, and a meeting ending exactly when another begins must free its room or you will overcount.
Was this answer helpful?
Likely follow-ups
- Now tell me which room each meeting goes in, not just how many rooms.
- The meetings arrive over time rather than being given up front. What changes?
- Rooms have capacities and meetings have attendee counts. Is this still the same problem?
- Report the busiest window, meaning the time span during which the maximum number of rooms is in use.
Related questions
- Given everyone's busy calendar, find the slots when all of them are free. What do you sort, and what breaks at the boundaries?mediumAlso on intervals and sweep-line5 min
- Merge a list of overlapping intervals, and justify the key you sorted byeasyAlso on intervals and sweep-line4 min
- Given a list of meetings with start and end times, pick the largest set of them that do not overlap.mediumAlso on sorting4 min
- Return every distinct triplet in the array that sums to zero.mediumAlso on sorting4 min