Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8b51bdb

Browse files
🐱(math): 836. 矩形重叠
1 parent bf11a1e commit 8b51bdb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎docs/algorithm/math/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,27 @@ class Solution:
484484
return "x=" + str(-num // x_count)
485485
```
486486

487+
## 836. 矩形重叠
488+
489+
[原题链接](https://leetcode-cn.com/problems/rectangle-overlap/)
490+
491+
### 思路
492+
493+
判断「不相交」的条件。
494+
495+
```python
496+
class Solution:
497+
def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:
498+
ax1, ay1 = rec1[0], rec1[1]
499+
ax2, ay2 = rec1[2], rec1[3]
500+
bx1, by1 = rec2[0], rec2[1]
501+
bx2, by2 = rec2[2], rec2[3]
502+
# 判断是否相交
503+
if ax2 <= bx1 or ax1 >= bx2 or ay2 <= by1 or ay1 >= by2:
504+
return False
505+
return True
506+
```
507+
487508
## 1103. 分糖果 II
488509

489510
[原题链接](https://leetcode-cn.com/problems/distribute-candies-to-people/)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /