LeetCode223——Rectangle Area
来源:互联网 发布:国家进出口数据 编辑:程序博客网 时间:2024/05/23 11:08
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.
Credits:
Special thanks to @mithmatt for adding this problem, creating the above image and all test cases
实现:
class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int val = (C-A)*(D-B) + (G-E)*(H-F);
if (E > C || G < A || F > D || H < B) {
return val;
}
val -= (min(C,G) - max(A,E))*(min(D,H) - max(B,F));
return val;
}
};
1 0
- LeetCode223——Rectangle Area
- LeetCode223:Rectangle Area
- leetcode223 :Rectangle Area
- leetcode223. Rectangle Area
- LeetCode223 Rectangle Area
- LeetCode——Rectangle Area
- Algorithms—223.Rectangle Area
- leetcode——223——Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- Rectangle Area
- mysql 递归查询的方法
- oc中的文件和目录相关操作
- dex文件结构分析-3
- linux查看用户命令
- 安装xmind出错:没有JRE
- LeetCode223——Rectangle Area
- 传入时间与现在时间的差距及其表示
- android事件传递机制的浅谈
- 高效学习有方法--自己的感悟
- Snail—UI学习之表视图TableView多行删除
- linux更换硬盘后的网络设置
- oc不可变字符串和可变字符串相关操作
- UL下拉列表 调出滑动条
- 随笔