Rectangle Area
class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
long total = max((C-A),0) * max((D-B),0) + max((G-E),0) * max((H-F),0) ;
long comm;
if(min(G,C) < max(E,A) || min(H,D) < max(F,B) ) //防止越界
comm = 0;
else
comm = max(0,min(G,C)-max(E,A)) * max(0,min(H,D)-max(F,B)) ;
return total-comm;
}
};
原题在此处 https://leetcode.com/problems/rectangle-area/
Rectangle Area的更多相关文章
- [LeetCode] Rectangle Area 矩形面积
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...
- [leetcode] Rectangle Area
Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...
- 【leetcode】Contains Duplicate & Rectangle Area(easy)
Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your funct ...
- [LeetCode] 850. Rectangle Area II 矩形面积之二
We are given a list of (axis-aligned) rectangles. Each rectangle[i] = [x1, y1, x2, y2] , where (x1, ...
- [LeetCode] 223. Rectangle Area 矩形面积
Find the total area covered by two rectilinearrectangles in a 2D plane. Each rectangle is defined by ...
- LeetCode 223. 矩形面积(Rectangle Area)
223. 矩形面积 223. Rectangle Area 题目描述 在二维平面上计算出两个由直线构成的矩形重叠后形成的总面积. 每个矩形由其左下顶点和右上顶点坐标表示,如图所示. LeetCode2 ...
- 【刷题-LeetCode】223. Rectangle Area
Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectang ...
- Java for LeetCode 223 Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
- (easy)LeetCode 223.Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
- leetcode:Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
随机推荐
- 配置Office 365单点登录摘要
O365: 如果O365账号之前做过测试,则停用同步,强制删除已有用户涉及命令:Remove-MsolUser -UserPrincipalName zhang_san@company.cn (-Re ...
- mysql 锁-比较详细、深入的介绍
详见:http://www.cnblogs.com/chenpingzhao/archive/2015/12/13/5041967.html
- java 反射获取类的属性 类型 名称和值
/** * 获取属性类型(type),属性名(name),属性值(value)的map组成的list * */ private List getFiledsInfo(Object o){ Field[ ...
- 在win10里打开.hlp文件
D7的帮助都是.hlp格式的, 目前win10还没有相应的补丁, 导致无法打开 自己手动来处理一下: 1. 下载连接中的winhlp32.rar, 这个是从XP系统里提取的 2. 修改windows ...
- 视图UIView的大小和位置属性详解
UIView类中定义了三个属性,分别是frame.bounds与center属性: IKit中的坐标系X轴正方向为水平向右,Y轴正方向为竖直向下. frame属性指的是视图在其父视图坐标系中的位置与尺 ...
- HTTP常见头域
近期没需求,也没什么心情去看书,就总结一下自己以前看的HTTP协议基础内容吧.(会很乱,可能不适合一点都没接触过HTTP协议的人观看) 一.HTTP Request header 1.Cache头域 ...
- WordPress多站点获取当前博客信息
http://www.utubon.com/1495/wordpress-multisite-get-current-bolg-info global $current_blog; 它的返回结果是: ...
- JSON语法五大要素图文介绍
原文:http://www.jb51.net/article/32398.htm JSON语法是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成,下面就进行学习研究,希望本文能教会 ...
- weblogic启动受管服务器报错Authentication for user weblogic denied (weblogic 11g 域账号密码不生效的解决方法)
或者 解决方法:
- Runtime实战之定制TabBarItem大小
方案一:UIEdgeInsets 适用场景: 适合APP的TabBarItemImage的图片资源放在本地 图片超出tabbar的高度,需移动其位置,来进行适应 弊端: 若在本地配置好后,tabbar ...