LeetCode-223. Rectangle Area (JAVA)求矩形覆盖面积
来源:互联网 发布:人才招聘系统源码 编辑:程序博客网 时间:2024/05/16 06:47
223. Rectangle Area
Find the total area covered by two rectilinear rectangles in a2D 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 ofint.
public int helper(int A, int B, int C, int D, int E, int F, int G, int H) {// 看图,上侧取小int up = Math.min(D, H);// 看图,下侧取大int down = Math.max(B, F);// 看图,右侧取小int right = Math.min(C, G);// 看图,左侧取大int left = Math.max(A, E);// 此种情况说明没有交集if (up < down || right < left) { return 0;} else {// 计算面积return (up - down) * (right - left);}}// A U B = A + B - A * Bpublic int computeArea(int A, int B, int C, int D,int E, int F, int G, int H) {// 求解两个矩形覆盖的面积,如果没有交集,则是两个面积之和return (C - A) * (D - B) + (G - E) * (H - F) - helper(A, B, C, D, E, F, G, H);}
0 0
- LeetCode-223. Rectangle Area (JAVA)求矩形覆盖面积
- leetcode 223. Rectangle Area-矩形面积
- leetcode 223. Rectangle Area 矩形面积计算
- leetcode_223. Rectangle Area 求两个矩形覆盖的面积之和
- (LeetCode)Rectangle Area --- 求图形覆盖的面积
- Leetcode 223 Rectangle Area 矩形区域面积
- LeetCode 223 Rectangle Area(矩形面积)
- 223. Rectangle Area (求两矩形重合部分的面积)
- LeetCode 223. Rectangle Area(两个矩形的复合面积计算)
- 求矩形覆盖面积
- Rectangle Area 两个矩形的面积
- Rectangle Area 两个矩形的面积
- Rectangle Area-带有交差集矩形面积
- 【leetcode】Rectangle Area【java】
- LeetCode----223. Rectangle Area 2个矩形和
- Leetcode:223. Rectangle Area(JAVA)
- [leetcode] 223.Rectangle Area
- [leetcode] 223. Rectangle Area
- CodeForces
- Android Service -远程服务
- Hibernate-helloWorld
- 我上世纪80年代编写的FORTRAN程序
- Java并发-Java内存模型的基础
- LeetCode-223. Rectangle Area (JAVA)求矩形覆盖面积
- Java集合学习
- table设置td文本超出为省略号无效的解决方法
- 学习小结y7
- 11--PHP中的类和对象
- C语言中的随机数问题
- JS学习-初学Ajax
- 秒杀多线程第十一篇 读者写者问题
- 进程与线程