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 ...
随机推荐
- 总结-EL表达式
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ tagl ...
- 提取本地环境中部署RDLC的DLL
要使用reportviewer来呈现报表,需要有三个dll Microsoft.ReportViewer.WinForms.DLL Microsoft.ReportViewer.WebForms.DL ...
- [原创]Hadoop默认设置导致NameNode启动失败一例
看到市面上很多书在讲解Hadoop的时候都轻描淡写的提到了HDFS的设置问题.大多采取的是默认设置,最多也就是设置一些副本数量之类. 笔者在工作中遇到了这样一种情况:每次重启系统之后,NameNode ...
- 移动端的传统click事件延迟和点透现象
一.场景描述: 1.A/B两个层上下z轴重叠. 2.上层的A点击后消失或移开.(这一点很重要) 3.B元素本身有默认click事件(如a标签) 或 B绑定了click事件. 在以上情况下,点击A/B重 ...
- charles Mock测试总结
转载:http://www.jianshu.com/p/03081c9d1559 1.背景 测试存在问题:1.测试环境接口不稳定2.业务系统不是孤立存在的,关联方太多,而且关联系统常常出现不稳定的情况 ...
- 利用pip安装模块(以安装pyperclip为例)
>任务:利用pip安装pyperclip模块 >前提:你已经在你的电脑里面安装啦Python2.7的Windows版本,并且已经配置了环境变量 >实现步骤 >>打开你的P ...
- how-to-install-siege-on-centos-7
https://www.joedog.org/siege-home/ https://roastahost.com/how-to-install-siege-on-centos-7/ (Works!) ...
- python操作word入门
1.安装pywin32 http://sourceforge.net/projects/pywin32 在files里去找适合你的python版本.截止此文,最新版本是pywin32-219快捷路径: ...
- create a inatll package
gcc -o hell t.c tar -jxf hell.tar.bz2 [root@localhost ~]# cat install.sh #!/bin/bashlines=7tail -n ...
- Unity Mono IDE Setting
Mac: 修改快捷键 删除一整行 Delete Entire Line Command+D Format Document Shift+Command+F 在文件中查找 Fin in Fil ...