194. Clash-Free Calendar
You are given a list of meetings. Each meeting [start, end] begins at minute start and finishes at minute end, so the minute end itself is already free again. A meeting that starts exactly when another one finishes is therefore fine.
Decide whether one person could attend every meeting: return true when no two meetings overlap, and false otherwise. The meetings are not given in any particular order, and the list may be empty.
Example 1
- Input:
- meetings = [[9,11],[11,12],[14,15]]
- Output:
- true
- Explanation:
The second meeting starts at 11, exactly when the first one ends, so there is no clash.
Example 2
- Input:
- meetings = [[1,4],[3,6]]
- Output:
- false
- Explanation:
The meetings share minutes 3 to 4, so one person cannot attend both.
Example 3
- Input:
- meetings = [[5,8]]
- Output:
- true
- Explanation:
A single meeting can always be attended.
Constraints
0 ≤ meetings.length ≤ 105
0 ≤ start < end ≤ 109
How this problem is judged
- Answers
- Your answer must match exactly. Numbers compare by value, so 2 and 2.0 are equal.
Expected complexity
- Time
- O(n log n)
- Space
- O(1)