class Solution { public boolean isRectangleOverlap(int[] rec1, int[] rec2) { final boolean isNotOverlapped = rec1[2] <= rec2[0] //>> rec1 is in the left of rec2 || rec1[3] <= rec2[1] //>> rec1 is in the bottom of rec2 || rec1[0] >= rec2[2] //>> rec1 is in the right of rec2 || rec1[1] >= rec2[3]; //>> rec1 is in the top of rec2 return !isNotOverlapped; } }