Problem statement

https://leetcode.com/problems/rectangle-overlap/

Solution

We need to solve two separate problems: for each of dimensions. See also 0223 Rectangle Area problem, this one is special case.

Complexity

Time and space complexity is O(1).

Code

class Solution:
    def isRectangleOverlap(self, rec1, rec2):
        A, B, C, D = rec1
        E, F, G, H = rec2
        return not min(C,G) <= max(A,E) and not min(D,H) <= max(B,F)