Leetcode 866 Solution
This article provides solution to leetcode question 866 (rectangle-overlap)
Access this page by simply typing in "lcs 866" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/rectangle-overlap
Solution
class Solution {
public:
bool isLineOverlap(int s1, int e1, int s2, int e2) {
int l = max(s1, s2);
int r = min(e1, e2);
return l < r;
}
bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {
return isLineOverlap(rec1[0], rec1[2], rec2[0], rec2[2]) && isLineOverlap(rec1[1], rec1[3], rec2[1], rec2[3]);
}
};