leetcode---Rectangle Area
来源:互联网 发布:八进制转十进制算法 编辑:程序博客网 时间:2024/06/01 08:45
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
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 a = max(A, E), b = max(B, F); //左下 int c = min(C, G), d = min(D, H); //右上 int s1 = (C-A) * (D-B); int s2 = (G-E) * (H-F); if(d <= b || c <= a) return s1 + s2; else return s1 + s2 - (c-a) * (d-b); }};
0 0
- leetcode Rectangle Area
- [LeetCode] Rectangle Area
- leetcode--Rectangle Area
- [LeetCode]Rectangle Area
- [leetcode] Rectangle Area
- Rectangle Area - LeetCode 223
- leetcode-Rectangle Area[math]
- leetCode 之 Rectangle Area
- leetcode 223: Rectangle Area
- [leetcode]Rectangle Area
- leetcode[223]:Rectangle Area
- LeetCode Rectangle Area
- [leetcode][math] Rectangle Area
- #leetcode#Rectangle Area
- [LeetCode] Rectangle Area
- LeetCode: Rectangle Area
- Leetcode 223 Rectangle Area
- [Leetcode]-Rectangle Area
- Java学习第四天总结循环语句
- 登录页面,ajax,layer
- Android 常见面试题 一
- The Perfect Stall
- 动态规划之-----单调递增最长子序列(nyoj17)
- leetcode---Rectangle Area
- Hark语音识别学习(一)-Hark desinger的使用
- 计算几何----判断两矩形是否相交
- B+树索引概述
- [MySQL]Innodb参数优化
- php使用ajax中文乱码问题
- const void* 指向的内存是否可改变
- (Caffe,LeNet)初始化测试网络(四)
- ubuntu下编写简单的helloworld程序