[LeetCode]Rectangle Area
2015-12-05 13:25
183 查看
public class Solution { public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int area = (C - A) * (D - B) + (G - E) * (H - F); if (C <= E || A >= G || B >= H || D <= F) { return area; } int x = Math.min(G, C) - Math.max(A, E); int y = Math.min(D, H) - Math.max(B, F); return area - x * y; } }
相关文章推荐
- [LeetCode]Flatten Binary Tree to Linked List
- JavaScript学习笔记(一)基本概念及基本数据类型
- 杭电acm4520
- android camera HAL v3.0中元数据及其控制
- 小王梦游记三
- 免费论文查重
- android项目双击或者多击的实现
- toast里的getApplicationContext与this的区别
- android 蓝牙4.2.2分析研究
- Linux ssh 不需要输入密码的方法
- OC 实例方法和类方法区别
- nyoj 115 城市平乱
- HTML5你不知道的那些功能
- Android 中的 Service 全面总结
- 路由方式,IP路由选择过程
- Fragment -- 整理篇
- Android Service与Activity之间通信的几种方式
- 马走日 java
- [深入浅出Windows 10]应用实战:Bing在线壁纸
- 使用UI Automation实现自动化测试 (InvokePattern)