Meeting Rooms
easy
arrays
intervals
sorting
Given an array of meeting time intervals where intervals[i] = [start_i, end_i], determine if a person could attend all meetings without any overlap.
Meetings that touch at a boundary (e.g. [1, 5] and [5, 8]) do not overlap and can both be attended.
Input / output
- Input:
intervals: int[][] - Output:
boolean—trueif no two meetings overlap,falseotherwise
Constraints
0 <= intervals.length <= 10^4intervals[i].length == 20 <= start_i < end_i <= 10^6
Follow-up
If the meetings do overlap, how do you find the minimum number of conference rooms required so every meeting can run? (See Meeting Rooms II.)
Examples
Example 1: overlapping meetings
Input: intervals = [[0,30],[5,10],[15,20]]
Output: false
Example 2: unsorted non-overlapping
Input: intervals = [[7,10],[2,4]]
Output: true
Example 3: back-to-back touching endpoints
Input: intervals = [[1,5],[5,8],[8,10]]
Output: true