leetcode Rectangle Area
来源:互联网 发布:追一个女生有多难 知乎 编辑:程序博客网 时间:2024/05/01 02:43
题目链接这里
思路:求交集再减并集
public class Solution { public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { if(A>E) { swap(A, E); swap(B,F); swap(C, G); swap(D, H); } int overlatpt=0; if(C<=E||B>=H||D<=F) { overlatpt=0; } else { int up=Math.min(D, H); int down=Math.max(B, F); int length=up-down; int left=Math.max(A, E); int right=Math.min(C, G); int width=right-left; overlatpt=length*width; } return (C-A)*(D-B)+(G-E)*(H-F)-overlatpt; } public static void swap(int A,int B) { int temp=A; A=B; B=temp; return; }}
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
- ionic使用记录------输入组件容器.item-input
- 网站网页变灰的网页代码怎么实现?
- CentOS 7 笔记
- java读取word目录
- 通过豆瓣Api,输入ISBN获取图书信息
- leetcode Rectangle Area
- 排颜色问题——数组 leetcode lintcode
- 配置jdk 环境变量
- Java中的String类常量池详解
- Tomcat优化实践——网站运维
- Xcode6中使用MJRefresh第三方库
- 关于C#泛型作用的简单说明
- 海事东北赛&&全国邀请赛总结
- 天锐绿盾注册机 使用手册