836. Rectangle Overlap
Description
Intuition
1D
For example, we have 2 segemnts (x1, x2), (x3, x4)
:
# case 1
x1 x2
| |
-----------------
x3 x4
| |
-----------------
# case 2
x1 x2
| |
-----------------
x3 x4
| |
-----------------
x1 < x4 && x3 < x2
2D
For 2d,
- horizontal
- must satisfy
x1 < x4 && x3 < x2
- must satisfy
- Vertical
- must satisfy
y1 < y4 && y3 < y2
- must satisfy