#Leetcode# 836. Rectangle Overlap
https://leetcode.com/problems/rectangle-overlap/
A rectangle is represented as a list [x1, y1, x2, y2]
, where (x1, y1)
are the coordinates of its bottom-left corner, and (x2, y2)
are the coordinates of its top-right corner.
Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.
Given two (axis-aligned) rectangles, return whether they overlap.
Example 1:
Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3]
Output: true
Example 2:
Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1]
Output: false
Notes:
- Both rectangles
rec1
andrec2
are lists of 4 integers. - All coordinates in rectangles will be between
-10^9
and10^9
.
代码:
class Solution {
public:
bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {
int A = rec1[0], B = rec1[1], C = rec1[2], D = rec1[3];
int E = rec2[0], F = rec2[1], G = rec2[2], H = rec2[3]; if (E >= C || F >= D || B >= H || A >= G) return false;
return true;
}
};
#Leetcode# 836. Rectangle Overlap的更多相关文章
- 【Leetcode_easy】836. Rectangle Overlap
problem 836. Rectangle Overlap solution: class Solution { public: bool isRectangleOverlap(vector< ...
- 836. Rectangle Overlap ——weekly contest 85
Rectangle Overlap A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coor ...
- 【LeetCode】836. Rectangle Overlap 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/rectangle ...
- [LeetCode&Python] Problem 836. Rectangle Overlap
A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bot ...
- [LeetCode] 836. Rectangle Overlap_Easy
A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bot ...
- 836. Rectangle Overlap 矩形重叠
[抄题]: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of i ...
- 836. Rectangle Overlap
class Solution { public: bool isRectangleOverlap(vector<int>& rec1, vector<int>& ...
- [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 ...
随机推荐
- Ubuntu教程
Ubuntu的发音 Ubuntu,源于非洲祖鲁人和科萨人的语言,发作 oo-boon-too 的音.了解发音是有意义的,您不是第一个为此困惑的人,当然,也不会是最后一个:) 大多数的美国人读 ubun ...
- kafka_2.11-2.0.0_常用操作
参考博文:Kafka消费组(consumer group) 参考博文:kafka 1.0 中文文档(九):操作 参考博文:kafka集群管理工具kafka-manager部署安装 以下操作可以在min ...
- SAP LOGON 快捷登陆方式如何保存密码
默认情况下,快捷方式密码是不能输入的. 解决方法:修改注册表: 计算机\HKEY_CURRENT_USER\Software\SAP\SAPShortcut\Security EnablePasswo ...
- bsp 总结
_board_128.c里放硬件不同的东西,如gpio等 product下code里面的cspkernel里面放内核模块补充的
- Git 遇到的坑
ssh出错 gitlab服务器添加完公钥之后,ssh服务器然后报了这个错误 sign_and_send_pubkey: signing failed: agent refused operation ...
- 【转】iOS弹幕库OCBarrage-如何hold住每秒5000条巨量弹幕
最近公司做新需求, 原来用的老弹幕库, 已经无法满足需要. 迫不得已自己写了一套弹幕库OCBarrage. 这套弹幕库轻量, 可拓展, 高度自定义, 超高性能, 简单易上手. 无论哪家公司软件的性能绝 ...
- 【vue】vue +element 搭建项目,this.$nextTick用法
相关资料:https://www.cnblogs.com/leaf930814/p/7247478.html https://www.cnblogs.com/duanyue/p/7458340.htm ...
- 008_python内置语法
一. 参考:http://www.runoob.com/python/python-built-in-functions.html (1)vars() 描述 vars() 函数返回对象object的属 ...
- ActiveMQ的作用总结(应用场景及优势)
业务场景说明: 消息队列在大型电子商务类网站,如京东.淘宝.去哪儿等网站有着深入的应用, 队列的主要作用是消除高并发访问高峰,加快网站的响应速度. 在不使用消息队列的情况下,用户的请求数据直接写入数据 ...
- day22 Pythonpython 本文xml模块
一.xml介绍 xml是实现不同语言或者程序直接进行数据交换的协议,跟json差不多,单json使用起来更简单.不过现在还有很多传统公司的接口主要是xml xml跟html都是标签语言 我们主要学习的 ...