Katkat

Compute conflicts and minimum meeting rooms

AppleSoftware Engineer · Technical Screen

Last updated

This question evaluates the ability to reason about interval overlaps and resource allocation, testing algorithmic thinking and efficient handling of time-interval data in scheduling contexts and belongs to the Coding & Algorithms domain.

You are given a list of meeting room booking requests. Each request is a half-open time interval [start, end), meaning it uses the room starting at start and releases it at end (so a meeting ending at time t does not overlap one starting at time t).

A single meeting room can host at most one request at any time.

Tasks

  1. Feasibility with one room: Determine whether all requests can be satisfied using only one meeting room (i.e., no time overlaps).
  2. Minimum rooms needed: If one room is not enough, compute the minimum number of meeting rooms required so that all requests can be satisfied.

Input / Output

  • Input: An array/list intervals of length n, where each element is [start, end) with start < end.
  • Output:
  • A boolean canScheduleInOneRoom.
  • An integer minRooms (the minimum number of rooms needed).

Constraints (assume)

  • 1 ≤ n ≤ 10^5
  • start and end are integers (or comparable timestamps) within a reasonable range.

Example

  • Input: [[0, 30], [5, 10], [15, 20]]
  • Output: canScheduleInOneRoom = false, minRooms = 2