leetcode836矩形重叠

class Solution:
    def isRectangleOverlap(self, rec1, rec2):
        """
        :type rec1: List[int]
        :type rec2: List[int]
        :rtype: bool
        """
        # 水平方向 0 2
        # 垂直方向 1 3

        xleft = max(rec1[0], rec2[0])
        xright = min(rec1[2], rec2[2])
        ytop = max(rec1[1], rec2[1])
        ydowm = min(rec1[3], rec2[3])

        if xleft < xright and ytop < ydowm:
            return True
        return False

猜你喜欢

转载自blog.csdn.net/weixin_36149892/article/details/80381674