De Morgan's Law and Boolean Algebra
De Morgan\'s Law tells us that the following are equivalent. An easy way to remember De Morgan\'s is by the saying to split the bar and change the operation; th
De Morgan\'s Law tells us that the following are equivalent. An easy way to remember De Morgan\'s is by the saying to split the bar and change the operation; that is to distribute negation and change the boolean operator in this example.\n\n```\n    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {\n        return !(rec1[2] <= rec2[0] ||   // left\n                 rec1[3] <= rec2[1] ||   // bottom\n                 rec1[0] >= rec2[2] ||   // right\n                 rec1[1] >= rec2[3]);    // top\n    }\n```\n\n```\n    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {\n        return   rec1[2] > rec2[0] &&   // left\n                 rec1[3] > rec2[1] &&   // bottom\n                 rec1[0] < rec2[2] &&   // right\n                 rec1[1] < rec2[3];     // top\n    }\n```\n\n
[]