Find the total area covered by two rectilinear rectangles in a 2D plane.

Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.

Rectangle Area
Assume that the total area is never beyond the maximum possible value of int.

Credits:
Special thanks to @mithmatt for adding this problem, creating the above image and all test cases.

### 思路

矩形1的面积 = (C-A) * (D-B)



### 代码

class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int w1 = abs(C-A);
int h1 = abs(D-B);
int w2 = abs(G-E);
int h2 = abs(H-F);
int w0 = abs(min(C,G) - max(A,E));
int h0 = abs(max(B,F) - min(D,H));
int a0 = w0*h0;
if(w1*h1==0||w1+w2<=max(abs(G-A),abs(C-E))||(h1+h2)<=max(abs(D-F),abs(H-B))) {
a0=0;
}
return w1*h1 + w2*h2 - a0;
}
};