Skip to content

Commit cceb094

Browse files
refactor 836
1 parent 73b9c38 commit cceb094

File tree

1 file changed

+3
-22
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-22
lines changed

src/main/java/com/fishercoder/solutions/_836.java

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 836. Rectangle Overlap
5-
*
6-
* A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of
7-
* its bottom-left corner, and (x2, y2) are the coordinates of its top-right corner.
8-
* Two rectangles overlap if the area of their intersection is positive.
9-
* To be clear, two rectangles that only touch at the corner or edges do not overlap.
10-
* Given two (axis-aligned) rectangles, return whether they overlap.
11-
*
12-
* Example 1:
13-
* Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
14-
* Output: true
15-
*
16-
* Example 2:
17-
* Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
18-
* Output: false
19-
*
20-
* Notes:
21-
* Both rectangles rec1 and rec2 are lists of 4 integers.
22-
* All coordinates in rectangles will be between -10^9 and 10^9.
23-
* */
243
public class _836 {
254
public static class Solution1 {
26-
/**credit: https://leetcode.com/problems/rectangle-overlap/discuss/132340/C%2B%2BJavaPython-1-line-Solution-1D-to-2D*/
5+
/**
6+
* credit: https://leetcode.com/problems/rectangle-overlap/discuss/132340/C%2B%2BJavaPython-1-line-Solution-1D-to-2D
7+
*/
278
public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
289
return rec1[0] < rec2[2] && rec2[0] < rec1[2] && rec1[1] < rec2[3] && rec2[1] < rec1[3];
2910
}

0 commit comments

Comments
 (0)