← Questions

Meeting rooms: find conflicts and the minimum rooms needed

0
AppleCodingLast asked Feb 2026

A coding interview question asked in Apple's technical phone screen, last asked Feb 2026. It tests intervals, sorting and heap.

You get meeting room requests as half-open intervals [start, end). A meeting that ends at t does not overlap one that starts at t. A room holds one meeting at a time. Answer two questions about the same list.

Part 1: one room

  • can_use_one_room(intervals: list[list[int]]) -> bool: True if no two requests overlap.

Part 2: fewest rooms

  • min_rooms(intervals: list[list[int]]) -> int: the fewest rooms that serve every request.

Example

[[1, 4], [2, 6], [5, 8], [8, 9]]    ->  False, 2
[[1, 3], [3, 5], [5, 8]]            ->  True, 1    # they only touch
[[9, 12], [1, 5], [2, 4], [3, 10]]  ->  False, 3   # 1-5, 2-4 and 3-10 all overlap at 3
[]                                  ->  True, 0

Constraints

  • 0 <= n <= 10^5; start < end, integers.
  • The input is not sorted.

Clarifying questions

  • Are the intervals half-open, so back-to-back meetings share a room?
  • Can the list be empty, and what should it return then?
  • Do you only need the count, or also which room each meeting gets?

What a strong answer covers

  • Part 1: sort by start and compare each meeting with the previous end, O(n log n).
  • Part 2: sort by start and keep a min-heap of end times, popping rooms that freed up by the next start; or sweep separate sorted start and end arrays. O(n log n) time, O(n) space.
  • At equal times, process the end before the start.
  • Tests: touching intervals, nested intervals, identical intervals, one interval.

Follow-ups

  • Return the room assigned to each meeting.
  • Requests arrive one at a time and must be accepted or refused immediately.
  • Each room has a capacity and each meeting a size.

Where it's asked

  • Apple · Technical phone screen · Last asked Feb 2026

What it tests

intervals · sorting · heap

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding