Meeting Rooms
Easy · intervals
You are given a list intervals, where each item [start, end] is one meeting. A meeting occupies the time from start up to, but not including, end.
Return True if one person can attend every meeting, and False if at least two meetings overlap. A meeting that ends at the exact moment another one starts does not overlap it, so [1, 5] and [5, 9] are fine back to back.
The meetings come in no particular order, and the list can be empty (then the answer is True).
Examples
Example 1
Input: intervals = [[0, 30], [5, 10], [15, 20]]
Output: False
The meeting [0, 30] is still running when [5, 10] starts, so you cannot be at both.
Example 2
Input: intervals = [[7, 10], [2, 4]]
Output: True
The list is not sorted, but [2, 4] is over before [7, 10] begins.
Example 3
Input: intervals = [[1, 5], [5, 9], [9, 12]]
Output: True
Each meeting ends exactly when the next one starts. That is allowed.
Constraints
- 0 <= len(intervals) <= 10^4
- intervals[i] has exactly two numbers, start and end
- -10^6 <= start < end <= 10^6