Rectangle Overlap
Two rectangles overlap if one’s maximum xcoordinate is greater than the other’s minimum xcoordinate and the maximum ycoordinate is greater than the other’s minimum ycoordinate. It is also necessary to ensure the minimum x and y of one rectangle is less than the maximum x and y of the other.
Python solution:


In this function, max(rec1[0], rec2[0]) < min(rec1[2], rec2[2])
checks the xcoordinates, and max(rec1[1], rec2[1]) < min(rec1[3], rec2[3])
checks the ycoordinates.
This solution is efficient with a time complexity of O(1), as it performs a constant number of operations, and a space complexity of O(1), as it uses a constant amount of space.