Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Runtime: 0 ms, faster than 100.00% of Java online submissions for Rectangle Overlap.
- // Memory Usage: 34.1 MB, less than 100.00% of Java online submissions for Rectangle Overlap.
- class Solution {
- public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
- int x1 = rec1[0];
- int y1 = rec1[1];
- int x2 = rec1[2];
- int y2 = rec1[3];
- int a1 = rec2[0];
- int b1 = rec2[1];
- int a2 = rec2[2];
- int b2 = rec2[3];
- return !(x2 <= a1 || a2 <= x1 || y2 <= b1 || b2 <= y1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement