Meeting Rooms
EasyIntervals
You are given an array of meeting time intervals intervals, where intervals[i] = [start, end] means a meeting runs from time start until time end. The meetings are not given in any particular order.
Return True if one person could attend all the meetings, or False if any two meetings overlap.
A meeting that ends at time t does not conflict with a meeting that starts at time t (the person can go straight from one to the next). Two meetings conflict if one starts strictly before the other ends.
Example 1
- Input:
- intervals = [[9, 12], [1, 4], [4, 9]]
- Output:
- True
- Explanation
- In time order the meetings are
[1, 4],[4, 9],[9, 12]. Each one starts exactly when the previous one ends, which is allowed, soTrue.
Example 2
- Input:
- intervals = [[2, 7], [8, 11], [6, 9]]
- Output:
- False
- Explanation
[6, 9]starts at 6, while[2, 7]is still running until 7, so the person cannot attend both.
Example 3
- Input:
- intervals = []
- Output:
- True
- Explanation
- With no meetings there is nothing to conflict.
Constraints
0 <= intervals.length <= 10^4intervals[i].length == 20 <= start < end <= 10^6