223. Rectangle Area
来源:互联网 发布:qq定位软件 编辑:程序博客网 时间:2024/06/18 05:58
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.
![Rectangle Area](https://leetcode.com/static/images/problemset/rectangle_area.png)
Assume that the total area is never beyond the maximum possible value of int.
public class Solution {
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {int l=0;
int d=0;
l=A<=E?helper(A,C,E,G):helper(E,G,A,C);
d=B<=F?helper(B,D,F,H):helper(F,H,B,D);
return total(A,B,C,D)+total(E,F,G,H)-l*d;
}
public int helper(int a,int b,int c,int d){
return b<c?0:(b<d?b:d)-c;
}
public int total(int a,int b,int c,int d){
return (c-a)*(d-b);
}
}
0 0
- 223. Rectangle Area
- [leetcode] 223.Rectangle Area
- [leetcode] 223. Rectangle Area
- 223. Rectangle Area LeetCode
- #leetcode# 223. Rectangle Area
- 223. Rectangle Area
- leetcode 223. Rectangle Area
- 223. Rectangle Area
- LeetCode--223. Rectangle Area
- 223. Rectangle Area
- LeetCode *** 223. Rectangle Area
- LeetCode 223. Rectangle Area
- leetcode-223. Rectangle Area
- 223. Rectangle Area
- 223. Rectangle Area
- LeetCode-223.Rectangle Area
- 223.[Leetcode]Rectangle Area
- 223. Rectangle Area
- 使用Ksoap2-Andorid调用WebService操作步骤
- Servlet的问题
- 权限管理,待整理,
- JavaWeb中的application统计在线人数案例
- 针对Apple Configurator 导出Profile文件
- 223. Rectangle Area
- Xcode 环境变量
- 2016 Macbook pro 4个口都能充电
- TensorFlow的reshape操作 tf.reshape
- 关于覆盖率GCOV(LCOV)
- 在idea上运行hadoop程序
- 谓词(NSPredicate)
- PHP SESSION原理
- exit函数