Solution with example diagrams
\nEvery rectangle has two unique x coordinates, and two unique y coordinates. In order for the rectangles to intersect, at least one x coordinate of a rectangle
![image](https://assets.leetcode.com/users/images/1c17e4aa-557e-416a-8155-9e904a2a85f0_1600243811.1408215.png)\nEvery rectangle has two unique x coordinates, and two unique y coordinates. In order for the rectangles to intersect, at least one x coordinate of a rectangle must be within the x coordinates of the other one (both x coordinates of the first may be within the x coordinates of the other one if the first one is completely contained in the second one). Thus, if all the x coordinates are sorted, the middle two give us the x-range of the intersection.\nSame argument applies to y coordinates.\n\n```\nclass Solution:\n    def isRectangleOverlap(self, r1: List[int], r2: List[int]) -> bool:\n        x = sorted([(r1[0], "r1"), (r1[2], "r1"), (r2[0], "r2"), (r2[2], "r2")])\n        y = sorted([(r1[1], "r1"), (r1[3], "r1"), (r2[1], "r2"), (r2[3], "r2")])\n        \n        if x[0][1] == x[1][1] or x[2][1] == x[3][1] or y[0][1] == y[1][1] or y[2][1] == y[3][1] or x[2][0] == x[1][0] or y[2][0] == y[1][0]:\n            return False\n        return True\n```\n\nIf the intersecting area was asked for, that\'s given by `x[2][0] - x[1][0]) * (y[2][0] - y[1][0]`.\nAlso see related problem https://leetcode.com/problems/rectangle-area/.\n\n\n
['Python', 'Python3']