# <LeetCode OJ> 223. Rectangle Area

Total Accepted: 38216 Total Submissions: 126941 Difficulty: Easy

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.

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

class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int result=(D-B)*(C-A)+(H-F)*(G-E);
//求取重叠部分的四个角坐标
int left = max(A, E);
int down = max(B, F);
int right = min(G, C);
int up = min(D, H);

if (up <= down || right <= left) //没有重叠
return result;

return  result - (right - left) * (up - down);
}
};

举报原因： 您举报文章： 223. Rectangle Area 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)