# Rectangle Area

class Solution:
# @param {integer} A
# @param {integer} B
# @param {integer} C
# @param {integer} D
# @param {integer} E
# @param {integer} F
# @param {integer} G
# @param {integer} H
# @return {integer}
def computeArea(self, A, B, C, D, E, F, G, H):
area1=(C-A)*(D-B)
area2=(G-E)*(H-F)
area_overlapped=0
print 'area1:',area1
print 'area2:',area2
x_overlapped=(A-G)*(C-E)
y_overlapped=(B-H)*(D-F)
if x_overlapped>=0 or y_overlapped>=0: #x and y not overlap
return area1+area2
else :
x1=max(A,E)
y1=max(B,F)
x2=min(C,G)
y2=min(D,H)
area_overlapped=(x2-x1)*(y2-y1)
print 'overlap:',area_overlapped
return area1+area2-area_overlapped

• 本文已收录于以下专栏：

## [Leetcode]-Rectangle Area

//题目:Find the total area covered by two rectilinear rectangles in a 2D plane. //Each rectangle is d...

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

【223-Rectangle Area（矩形区域）】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题...

## LeetCode 223 Rectangle Area（矩形面积）

• NoMasp
• 2016-01-27 12:17
• 2132

## 204. Count Primes \ 223. Rectangle Area

Rectangle Area Count Primes223. Rectangle Areaclass Solution { public: int computeArea(int A, in...

## LeetCode Rectangle Area

LeetCode Rectangle Area题目思路刚开始自己写别提WA多少遍了； 后来看到标达真的被惊讶到了； 代码可以这么美；代码自己的#define min(A, B) (A > B ? ...

## Leetcode 223 - Rectangle Area（矩形面积交）

• Lzedo
• 2017-03-06 11:00
• 90

## Rectangle Area

Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)