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 ...
随机推荐
- Tomcat常见问题汇总
1.在服务器上一定要开启-server参数 #直接在一堆注释下添加即可 #即是在 # OS specific support.注释之前 JAVA_OPTS= -server 2.tomcat启动很慢 ...
- asp.net mvc 过滤器
https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters#ordering 1. 对于应用在 Action 上的多个行为 ...
- linux-shell笔记
1.当从windows拖到shell中无法传递文件时,多半可能没有权限,可用sudo rz来进行手动选择传递 2.连接虚拟机时,ssh 用户名@ip地址,然后会提示输入该虚拟机密码,输入密码即可连接 ...
- Java中OutOfMemoryError(内存溢出)的三种情况及解决办法
转载自:http://blog.sina.com.cn/s/blog_701c951f0100n1sp.html 相信有一定java开发经验的人或多或少都会遇到OutOfMemoryError的问题, ...
- HTML第二本书学习后记
1,换行标记<br>,不换行标记<nobr></nobr> 2,添加水平线 <hr> 3,插入特殊符号: 空格   " ...
- Stack的c实现
用c语言实现stack的初始化,push,pop和Clear操作 #include<stdio.h> #include<stdlib.h> #include<assert ...
- JMeter学习-023-JMeter 命令行(非GUI)模式详解(一)-执行、输出结果及日志、简单分布执行脚本
前文 讲述了JMeter分布式运行脚本,以更好的达到预设的性能测试(并发)场景.同时,在前文的第一章节中也提到了 JMeter 命令行(非GUI)模式,那么此文就继续前文,针对 JMeter 的命令行 ...
- ActiveMQ简介
ActiveMQ 1.ActiveMQ是什么ActiveMQ是Apache推出的一款开源的完全支持JMS1.1和J2EE1.4规范的JMS Provider实现的消息中间件(Message Orien ...
- oracle使用DataBase Configuration Assistant创建、删除数据库
可以使用DataBase Configuration Assistant来创建一个心得数据库.Database Configuration Assistant简称是DBCA,是创建.配置以及管理数据库 ...
- iBatis简单入门教程
iBatis 简介: iBatis 是apache 的一个开源项目,一个O/R Mapping 解决方案,iBatis 最大的特点就是小巧,上手很快.如果不需要太多复杂的功能,iBatis 是能够满足 ...