Class Solution
java.lang.Object
g0801_0900.s0836_rectangle_overlap.Solution
836 - Rectangle Overlap.<p>Easy</p>
<p>An axis-aligned rectangle is represented as a list <code>[x1, y1, x2, y2]</code>, where <code>(x1, y1)</code> is the coordinate of its bottom-left corner, and <code>(x2, y2)</code> is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.</p>
<p>Two rectangles overlap if the area of their intersection is <strong>positive</strong>. To be clear, two rectangles that only touch at the corner or edges do not overlap.</p>
<p>Given two axis-aligned rectangles <code>rec1</code> and <code>rec2</code>, return <code>true</code> <em>if they overlap, otherwise return</em> <code>false</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> rec1 = [0,0,2,2], rec2 = [1,1,3,3]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> rec1 = [0,0,1,1], rec2 = [1,0,2,1]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> rec1 = [0,0,1,1], rec2 = [2,2,3,3]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>rect1.length == 4</code></li>
<li><code>rect2.length == 4</code></li>
<li><code>-10<sup>9</sup> <= rec1[i], rec2[i] <= 10<sup>9</sup></code></li>
<li><code>rec1</code> and <code>rec2</code> represent a valid rectangle with a non-zero area.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isRectangleOverlap
public boolean isRectangleOverlap(int[] rec1, int[] rec2)
-