Advertisement
K_S_

Untitled

Nov 24th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. // Runtime: 0 ms, faster than 100.00% of Java online submissions for Rectangle Overlap.
  2. // Memory Usage: 34.1 MB, less than 100.00% of Java online submissions for Rectangle Overlap.
  3.  
  4. class Solution {
  5.     public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
  6.         int x1 = rec1[0];
  7.         int y1 = rec1[1];
  8.         int x2 = rec1[2];
  9.         int y2 = rec1[3];
  10.  
  11.         int a1 = rec2[0];
  12.         int b1 = rec2[1];
  13.         int a2 = rec2[2];
  14.         int b2 = rec2[3];
  15.  
  16.         return !(x2 <= a1 || a2 <= x1 || y2 <= b1 || b2 <= y1);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement