Last updated 3 years ago
just draw the pic,
draw the ways of no interaction in left, right, top , buttom, then can conduct the result.
time: O(1)
space:(1)
class Solution { public boolean isRectangleOverlap(int[] rec1, int[] rec2) { return !(rec1[2] <= rec2[0] || rec1[0] >= rec2[2] || rec1[1] >= rec2[3] || rec1[3] <= rec2[1]); } }