1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/完美矩形 [perfect-rectangle].html

37 lines
1.9 KiB
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>给你一个数组 <code>rectangles</code> ,其中 <code>rectangles[i] = [x<sub>i</sub>, y<sub>i</sub>, a<sub>i</sub>, b<sub>i</sub>]</code> 表示一个坐标轴平行的矩形。这个矩形的左下顶点是 <code>(x<sub>i</sub>, y<sub>i</sub>)</code> ,右上顶点是 <code>(a<sub>i</sub>, b<sub>i</sub>)</code></p>
<p>如果所有矩形一起精确覆盖了某个矩形区域,则返回 <code>true</code> ;否则,返回 <code>false</code></p>
&nbsp;
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/27/perectrec1-plane.jpg" style="height: 294px; width: 300px;" />
<pre>
<strong>输入:</strong>rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]
<strong>输出:</strong>true
<strong>解释:</strong>5 个矩形一起可以精确地覆盖一个矩形区域。
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/27/perfectrec2-plane.jpg" style="height: 294px; width: 300px;" />
<pre>
<strong>输入:</strong>rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]
<strong>输出:</strong>false
<strong>解释:</strong>两个矩形之间有间隔,无法覆盖成一个矩形。</pre>
<p><strong>示例 3</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/27/perfecrrec4-plane.jpg" style="height: 294px; width: 300px;" />
<pre>
<strong>输入:</strong>rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]
<strong>输出:</strong>false
<strong>解释:</strong>因为中间有相交区域,虽然形成了矩形,但不是精确覆盖。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= rectangles.length &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>rectangles[i].length == 4</code></li>
<li><code>-10<sup>5</sup> &lt;= x<sub>i</sub>, y<sub>i</sub>, a<sub>i</sub>, b<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
</ul>