1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/矩形重叠 [rectangle-overlap].html
2022-03-29 12:43:11 +08:00

40 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>矩形以列表 <code>[x1, y1, x2, y2]</code> 的形式表示,其中 <code>(x1, y1)</code> 为左下角的坐标,<code>(x2, y2)</code> 是右上角的坐标。矩形的上下边平行于 x 轴,左右边平行于 y 轴。</p>
<p>如果相交的面积为 <strong></strong> ,则称两矩形重叠。需要明确的是,只在角或边接触的两个矩形不构成重叠。</p>
<p>给出两个矩形 <code>rec1</code><code>rec2</code> 。如果它们重叠,返回 <code>true</code>;否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>rec1 = [0,0,2,2], rec2 = [1,1,3,3]
<strong>输出:</strong>true
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>rec1 = [0,0,1,1], rec2 = [1,0,2,1]
<strong>输出:</strong>false
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>rec1 = [0,0,1,1], rec2 = [2,2,3,3]
<strong>输出:</strong>false
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>rect1.length == 4</code></li>
<li><code>rect2.length == 4</code></li>
<li><code>-10<sup>9</sup> &lt;= rec1[i], rec2[i] &lt;= 10<sup>9</sup></code></li>
<li><code>rec1</code><code>rec2</code> 表示一个面积不为零的有效矩形</li>
</ul>