leetcode 矩形重叠 简单

时间:2021-09-01 13:26:21   收藏:0   阅读:9

技术分享图片

 

 

看代码:

class Solution {
public:
    bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {
        int x1 = max(rec1[0], rec2[0]), y1 = max(rec1[1], rec2[1]);
        int x2 = min(rec1[2], rec2[2]), y2 = min(rec1[3], rec2[3]);
        if(x1 >= x2 || y1 >= y2) return false;
        return true;
    }
};

 

原文:https://www.cnblogs.com/rookie-acmer/p/15208261.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!