Class Solution
java.lang.Object
g0301_0400.s0391_perfect_rectangle.Solution
391 - Perfect Rectangle.<p>Hard</p>
<p>Given an array <code>rectangles</code> where <code>rectangles[i] = [x<sub>i</sub>, y<sub>i</sub>, a<sub>i</sub>, b<sub>i</sub>]</code> represents an axis-aligned rectangle. The bottom-left point of the rectangle is <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and the top-right point of it is <code>(a<sub>i</sub>, b<sub>i</sub>)</code>.</p>
<p>Return <code>true</code> <em>if all the rectangles together form an exact cover of a rectangular region</em>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/03/27/perectrec1-plane.jpg" alt="" /></p>
<p><strong>Input:</strong> rectangles = [[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> All 5 rectangles together form an exact cover of a rectangular region.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/03/27/perfectrec2-plane.jpg" alt="" /></p>
<p><strong>Input:</strong> rectangles = [[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> Because there is a gap between the two rectangular regions.</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/03/27/perfectrec3-plane.jpg" alt="" /></p>
<p><strong>Input:</strong> rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[3,2,4,4]]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> Because there is a gap in the top center.</p>
<p><strong>Example 4:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/03/27/perfecrrec4-plane.jpg" alt="" /></p>
<p><strong>Input:</strong> rectangles = [[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> Because two of the rectangles overlap with each other.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= rectangles.length <= 2 * 10<sup>4</sup></code></li>
<li><code>rectangles[i].length == 4</code></li>
<li><code>-10<sup>5</sup> <= x<sub>i</sub>, y<sub>i</sub>, a<sub>i</sub>, b<sub>i</sub> <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isRectangleCover
public boolean isRectangleCover(int[][] rectangles)
-