Rectangle Overlap – Python 3 (Week 10 – 09)

class Solution:
    def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:
       
       return not (rec2[0] >= rec1[2] or rec2[2] <= rec1[0] or rec2[3] <= rec1[1] or rec2[1] >= rec1[3])

Time O(1). Space O(1).

Leave a comment

Design a site like this with WordPress.com
Get started