Compute minimum rooms for time intervals
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
You are given a list of meeting time intervals, where each interval is represented as `[start, end)` (start time inclusive, end time exclusive) and `start < end`.
Two meetings overlap if one starts before the other ends.
**Task:** Return the minimum number of conference rooms required so that all meetings can be held without conflicts.
### Input
- `intervals`: an array of `n` intervals, each interval is a pair of integers `[start, end)`.
### Output
- An integer: the minimum number of rooms needed.
### Constraints (typical interview constraints)
- `1 <= n <= 10^5`
- `0 <= start < end <= 10^9`
### Example
- Input: `[[0,30],[5,10],[15,20]]`
- Output: `2` (because at time 5–10, two meetings overlap)
Quick Answer: This question evaluates understanding of interval overlap, resource allocation and the ability to implement efficient scheduling algorithms for meeting-room assignment.
You are given a list of meeting time intervals, where each interval is represented as [start, end). The start time is inclusive and the end time is exclusive. Return the minimum number of conference rooms required so that all meetings can be held without conflicts.
Two meetings overlap if one starts before the other ends. Because the end time is exclusive, a meeting that ends at time t does not conflict with a meeting that starts at time t.
The intervals may be given in any order.
Constraints
- 1 <= len(intervals) <= 10^5
- 0 <= start < end <= 10^9
- Intervals may be unsorted
Examples
Input: [[0, 30], [5, 10], [15, 20]]
Expected Output: 2
Explanation: The meeting [0,30) overlaps with both [5,10) and [15,20), but [5,10) and [15,20) do not overlap each other. At most 2 rooms are needed.
Input: [[1, 2]]
Expected Output: 1
Explanation: Only one meeting exists, so one room is enough.
Hints
- Try sorting all start times and all end times separately, then sweep through time.
- If the next meeting starts at or after the earliest ending meeting, that room can be reused because intervals are [start, end).