###### Easy-题目42：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 int.

class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int area = (C-A)*(D-B) + (G-E)*(H-F);
if (A >= G || B >= H || C <= E || D <= F)
return area;
int top = min(D, H);
int bottom = max(B, F);
int left = max(A, E);
int right = min(C, G);
return area - (top-bottom)*(right-left);
}
};

36ms,beats 20.05%，众数36ms,37.38%.

#### [leetcode-223]Rectangle Area(c++)

2015-08-25 10:09:39

#### 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

#### leetcode 223 Rectangle Area C++

2016-06-05 15:44:58

#### [LeetCode 223] Rectangle Area

2015-09-24 03:27:17

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

2015-08-29 06:39:48

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

2015-08-28 17:51:41

#### 223. Rectangle Area LeetCode

2016-02-12 12:34:51

#### 223. Rectangle Area

2015-06-26 09:05:42

## 不良信息举报

Easy-题目42：223. Rectangle Area