LeetCode 836 Rectangle Overlap

LeetCode 836 Rectangle Overlap Problem

Download Code
class Solution(object):
    def isRectangleOverlap(self, rec1, rec2):
        :type rec1: List[int]
        :type rec2: List[int]
        :rtype: bool
        return not (rec1[2] <= rec2[0] or  # left
                    rec1[3] <= rec2[1] or  # bottom
                    rec1[0] >= rec2[2] or  # right
                    rec1[1] >= rec2[3])    # top

    # def isRectangleOverlap(self, rec1, rec2):
    #     def intersect(p_left, p_right, q_left, q_right):
    #         return min(p_right, q_right) > max(p_left, q_left)
    #     return (intersect(rec1[0], rec1[2], rec2[0], rec2[2]) and
    #             intersect(rec1[1], rec1[3], rec2[1], rec2[3]))
Download Rectangle Overlap.py

List of all Rectangle Overlap problems

Leetcode 836 Rectangle Overlap problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.