Skip to content

Commit 008a5d6

Browse files
committed
update 729 comment, cheatsheet
1 parent cc32d53 commit 008a5d6

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

doc/cheatsheet/intervals.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Intervals
22
- [fucking algorithm : interval merge](https://github.com/labuladong/fucking-algorithm/blob/master/%E7%AE%97%E6%B3%95%E6%80%9D%E7%BB%B4%E7%B3%BB%E5%88%97/%E5%8C%BA%E9%97%B4%E8%B0%83%E5%BA%A6%E9%97%AE%E9%A2%98%E4%B9%8B%E5%8C%BA%E9%97%B4%E5%90%88%E5%B9%B6.md)
33
- [fucking algorithm : interval overlap](https://github.com/labuladong/fucking-algorithm/blob/master/%E7%AE%97%E6%B3%95%E6%80%9D%E7%BB%B4%E7%B3%BB%E5%88%97/%E5%8C%BA%E9%97%B4%E4%BA%A4%E9%9B%86%E9%97%AE%E9%A2%98.md)
4+
- [Visualization explaination](https://github.com/yennanliu/CS_basics/blob/master/doc/cheatsheet/array_overlap_explaination.md
5+
)
6+
47

58
## 0) Concept
69

@@ -20,6 +23,8 @@
2023
- LC 207, 210
2124
- Meeting room problems
2225
- LC 252, 253
26+
- Check if overlap existed
27+
- LC 729
2328

2429
- Algorithm
2530
- array op
@@ -29,7 +34,45 @@
2934
- array
3035
- dict
3136

37+
3238
### 0-2) Pattern
39+
40+
41+
42+
#### 0-2-1) Check if 2 intervals are overlap
43+
44+
- LC 729
45+
- https://github.com/yennanliu/CS_basics/blob/master/leetcode_java/src/main/java/LeetCodeJava/Array/MyCalendar1.java
46+
47+
48+
- *Conclusion*:
49+
if `start < date.get(1) and end > date.get(0)`
50+
-> then intervals are OVERLAP
51+
52+
- Overlap cases
53+
54+
```
55+
# case 1
56+
57+
New: |-------|
58+
Existing: |------|
59+
60+
61+
# case 2
62+
63+
New: |---|
64+
Existing: |-------|
65+
66+
# case 3
67+
68+
New: |-----------|
69+
Existing: |-----|
70+
71+
72+
73+
-> All of cases above are with `start < date.get(1) and end > date.get(0)` condition
74+
```
75+
3376
```python
3477
# python
3578

leetcode_java/src/main/java/LeetCodeJava/Array/MyCalendar1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class MyCalendar1 {
4949

5050
// V0
5151
// IDEA : BRUTE FORCE (fixed by gpt)
52+
// detailed explain : https://github.com/yennanliu/CS_basics/blob/master/doc/cheatsheet/array_overlap_explaination.md
5253
class MyCalendar {
5354
List<List<Integer>> dates;
5455

0 commit comments

Comments
 (0)