Skip to content

Commit 425c692

Browse files
committed
update: 模板题4 - Conflicting Appointments
1 parent 2a1089d commit 425c692

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

merge-intervals.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,36 @@ class Solution(object):
205205

206206
- **Time complexity**: As we are iterating through both the lists once, the time complexity of the above algorithm is **O(N + M)**, where ‘N’ and ‘M’ are the total number of intervals in the input arrays respectively.
207207

208-
- **Space complexity**: Ignoring the space needed for the result list, the algorithm runs in constant space **O(1)**.
208+
- **Space complexity**: Ignoring the space needed for the result list, the algorithm runs in constant space **O(1)**.
209+
210+
211+
212+
## 模板题4 - Conflicting Appointments
213+
214+
#### 题目
215+
216+
Given an array of intervals representing ‘N’ appointments, find out if a person can **attend all the appointments**.
217+
218+
**Example 1:**
219+
220+
```
221+
Appointments: [[1,4], [2,5], [7,9]]
222+
Output: false
223+
Explanation: Since [1,4] and [2,5] overlap, a person cannot attend both of these appointments.
224+
```
225+
226+
**Example 2:**
227+
228+
```
229+
Appointments: [[6,7], [2,4], [8,12]]
230+
Output: true
231+
Explanation: None of the appointments overlap, therefore a person can attend all of them.
232+
```
233+
234+
**Example 3:**
235+
236+
```
237+
Appointments: [[4,5], [2,3], [3,6]]
238+
Output: false
239+
Explanation: Since [4,5] and [3,6] overlap, a person cannot attend both of these appointments.
240+
```

0 commit comments

Comments
 (0)