您的位置:首页 > 其它

[LeetCode]Rectangle Area

2015-12-05 13:25 183 查看
public 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 (C <= E || A >= G || B >= H || D <= F) {
return area;
}
int x = Math.min(G, C) - Math.max(A, E);
int y = Math.min(D, H) - Math.max(B, F);
return area - x * y;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: