# LeetCode 223 Rectangle Area

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 in.

public class Solution {
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int area1 = (C - A) * (D - B);
int area2 = (G - E) * (H - F);
int buttom = Math.max(B, F);
int top = Math.min(D, H);
int right = Math.min(C, G);
int left = Math.max(A, E);
int both;
if(buttom > top || left > right) {
both = 0;
}
else {
both = (top - buttom) * (right - left);
}
return area1 + area2 - both;
}
}

#### leetcode 223: Rectangle Area

2015-06-10 03:25:56

#### 【LeetCode-223】 Rectangle Area(C++)

2016-05-11 22:20:23

#### Leetcode_223_Rectangle Area

2015-07-13 22:02:28

#### 223. Rectangle Area [easy] (Python)

2016-06-15 11:24:21

#### Leetcode 223 Rectangle Area 矩形区域面积

2015-08-28 17:51:41

#### 【LeetCode-面试算法经典-Java实现】【223-Rectangle Area（矩形区域）】

2015-08-29 06:39:48

#### LeetCode 223:Rectangle Area

2015-12-24 10:35:02

#### leetcode[223]:Rectangle Area

2015-06-12 21:00:37

#### [leetcode 223] Rectangle Area

2015-11-19 12:33:12

#### leetcode 223:Rectangle Area

2015-07-05 10:50:39