Rectangle Overlap
Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
Output: trueInput: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
Output: falseInput: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
Output: trueInput: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
Output: falseclass Solution {
public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
return (Math.max(rec1[0], rec2[0]) < Math.min(rec1[2], rec2[2])
&& Math.max(rec1[1], rec2[1]) < Math.min(rec1[3], rec2[3]));
}
}