Compute conflicts and minimum meeting rooms
AppleSoftware Engineer · Technical ScreenLast 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
- Feasibility with one room: Determine whether all requests can be satisfied using only one meeting room (i.e., no time overlaps).
- 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
intervalsof lengthn, where each element is[start, end)withstart < end. - Output:
- A boolean
canScheduleInOneRoom. - An integer
minRooms(the minimum number of rooms needed).
Constraints (assume)
1 ≤ n ≤ 10^5startandendare integers (or comparable timestamps) within a reasonable range.
Example
- Input:
[[0, 30], [5, 10], [15, 20]] - Output:
canScheduleInOneRoom = false,minRooms = 2
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.