# My solution 2333333333333333333

• ``````// author ： s2003zy.com
// weibo : weibo.com/songzy982
class Solution {

struct Point {
int x, y;
Point(int xx, int yy) : x(xx), y(yy) {}
};
struct Rectangle {
Point lb, ur;
Rectangle(const Point &a, const Point &b) : lb(a), ur(b) {}
int size() {
return (ur.x - lb.x) * (ur.y - lb.y);
}
int inter(const Rectangle &a) {
int maxLeft  = max(this -> lb.x, a.lb.x);
int minRight = min(this -> ur.x, a.ur.x);
int minUpper = min(this -> ur.y, a.ur.y);
int maxLower = max(this -> lb.y, a.lb.y);
return (minRight - maxLeft) * (minUpper - maxLower);
}
};
public:
bool overLapping(const Rectangle &a, const Rectangle &b) {
if (a.ur.x < b.lb.x) return false;
if (a.ur.y < b.lb.y) return false;
if (b.ur.x < a.lb.x) return false;
if (b.ur.y < a.lb.y) return false;
return true;
}
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
Rectangle ra( Point(A, B), Point(C, D) );
Rectangle rb( Point(E, F), Point(G, H) );
if (!overLapping(ra, rb)) {
return ra.size() + rb.size();
}
return ra.size() + rb.size() - ra.inter(rb);
}
};``````

• are you from China??

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.