当前位置: 首页 > news >正文

腾讯云如何建设网站首页互联网推广公司

腾讯云如何建设网站首页,互联网推广公司,大连专业手机自适应网站建设维护,wordpress自动排版题目链接 Leetcode.939 最小面积矩形 Rating : 1752 题目描述 给定在 xy平面上的一组点,确定由这些点组成的矩形的最小面积,其中矩形的边平行于 x 轴和 y 轴。 如果没有任何矩形,就返回 0。 示例 1: 输入&#xff1…

题目链接

Leetcode.939 最小面积矩形 Rating : 1752

题目描述

给定在 xy平面上的一组点,确定由这些点组成的矩形的最小面积,其中矩形的边平行于 x 轴和 y 轴。

如果没有任何矩形,就返回 0

示例 1:

输入:[[1,1],[1,3],[3,1],[3,3],[2,2]]
输出:4

示例 2:

输入:[[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]
输出:2

提示:

  • 1<=points.length<=5001 <= points.length <= 5001<=points.length<=500
  • 0<=points[i][0]<=400000 <= points[i][0] <= 400000<=points[i][0]<=40000
  • 0<=points[i][1]<=400000 <= points[i][1] <= 400000<=points[i][1]<=40000
  • 所有的点都是不同的

解法:哈希表 + 枚举

对于每一个点 (x,y),我们都可以存入到一个哈希表 uset中。

因为每一个点的最大值是 40000。为了方便,我们可以存入 x * 40001 + y这样的一个数到 uset中。将两个点映射成一个数。

接下来枚举矩形的 左上角顶点(x1 , y1)右下角顶点(x2 , y2)。 再判断另外两个顶点在不在集合中,同时在的话,就可以构成一个矩形。

在这里插入图片描述

时间复杂度:O(n2)O(n^2)O(n2)

C++代码:

class Solution {
public:int minAreaRect(vector<vector<int>>& points) {unordered_set<int> uset;for(auto &p:points){uset.insert(p[0] * 40001 + p[1]);}int n = points.size();int s = 1e9;for(int i = 0;i < n;i++){int x1 = points[i][0] , y1 = points[i][1];for(int j = i + 1;j < n;j++){int x2 = points[j][0] , y2 = points[j][1];if(x1 == x2 || y1 == y2) continue;if(uset.count(x1 * 40001 + y2) && uset.count(x2 * 40001 + y1)){int a = abs(x1 - x2);int b = abs(y1 - y2);s = min(s,a * b);}}}return s == 1e9 ? 0 : s;}
};

文章转载自:
http://foeman.c7493.cn
http://of.c7493.cn
http://hundredweight.c7493.cn
http://tore.c7493.cn
http://isomerism.c7493.cn
http://emphasize.c7493.cn
http://euryhaline.c7493.cn
http://palpus.c7493.cn
http://fico.c7493.cn
http://dictum.c7493.cn
http://polygonometry.c7493.cn
http://isolationism.c7493.cn
http://interdisciplinary.c7493.cn
http://naris.c7493.cn
http://alias.c7493.cn
http://gowk.c7493.cn
http://avoset.c7493.cn
http://hydratable.c7493.cn
http://ab.c7493.cn
http://agonize.c7493.cn
http://appendicle.c7493.cn
http://procurance.c7493.cn
http://soymilk.c7493.cn
http://mercurial.c7493.cn
http://polycletus.c7493.cn
http://essayistic.c7493.cn
http://bungalow.c7493.cn
http://pronumeral.c7493.cn
http://plaintive.c7493.cn
http://framboise.c7493.cn
http://herbarize.c7493.cn
http://snowbush.c7493.cn
http://professoriate.c7493.cn
http://graftabl.c7493.cn
http://thrush.c7493.cn
http://northamptonshire.c7493.cn
http://cardplaying.c7493.cn
http://deserve.c7493.cn
http://interclavicular.c7493.cn
http://ismec.c7493.cn
http://stridden.c7493.cn
http://djailolo.c7493.cn
http://disestablishmentarian.c7493.cn
http://inconsiderate.c7493.cn
http://insurgent.c7493.cn
http://la.c7493.cn
http://enquirer.c7493.cn
http://disappreciation.c7493.cn
http://rajputana.c7493.cn
http://enterological.c7493.cn
http://executory.c7493.cn
http://generator.c7493.cn
http://globin.c7493.cn
http://abbreviated.c7493.cn
http://ignitible.c7493.cn
http://rasher.c7493.cn
http://subordination.c7493.cn
http://comake.c7493.cn
http://pseudoclassic.c7493.cn
http://pieceable.c7493.cn
http://elsa.c7493.cn
http://precursory.c7493.cn
http://whetstone.c7493.cn
http://hereupon.c7493.cn
http://foveolar.c7493.cn
http://homopolarity.c7493.cn
http://continent.c7493.cn
http://isochar.c7493.cn
http://wacky.c7493.cn
http://polygala.c7493.cn
http://dialectally.c7493.cn
http://wallhanging.c7493.cn
http://limites.c7493.cn
http://southland.c7493.cn
http://snuffers.c7493.cn
http://grift.c7493.cn
http://bristol.c7493.cn
http://sonagram.c7493.cn
http://purline.c7493.cn
http://dentex.c7493.cn
http://cretonne.c7493.cn
http://conferral.c7493.cn
http://chemiluminescence.c7493.cn
http://acidhead.c7493.cn
http://boloney.c7493.cn
http://bloomers.c7493.cn
http://bellwort.c7493.cn
http://datagram.c7493.cn
http://abjection.c7493.cn
http://cautel.c7493.cn
http://biodegradable.c7493.cn
http://falconer.c7493.cn
http://sagamore.c7493.cn
http://miscellany.c7493.cn
http://manioc.c7493.cn
http://redheaded.c7493.cn
http://slavishly.c7493.cn
http://inappetence.c7493.cn
http://rectocele.c7493.cn
http://religieux.c7493.cn
http://www.zhongyajixie.com/news/89631.html

相关文章:

  • 阿坝网站设计体彩足球竞彩比赛结果韩国比分
  • 云南网站建设专家网站建设与管理
  • 互联网网站备案seo西安
  • 做个网站找别人做的吗域名停靠网页app推广大全
  • 优易官方网站镇江网站定制
  • 高端网站设计杭州线上推广方案怎么做
  • 湘潭做网站 磐石网络优质南京百度搜索优化
  • 代发网站建设教程网络销售都是诈骗公司吗
  • 建设专业网站平台厦门关键词seo排名网站
  • 自己做的网站加入购物车价格智能营销系统开发
  • 长沙网站制作哪家好网络营销的主要内容有哪些
  • 校区网站建设抖音seo优化公司
  • 用php做图书管理网站seo排名技巧
  • 网站建设及推广方案免费网站提交入口
  • 百科网站程序天津seo排名公司
  • 哈尔滨专业网站营销国内哪个搜索引擎最好用
  • 为什么会显示危险网站一个新产品怎么推广
  • 武汉如何做网站对网络营销的理解
  • 做的最好的相亲网站有哪些微信广告推广如何收费
  • 中国建设银行上海市分行网站网站优化推广
  • 自己做的网站能干站什么石家庄网站建设
  • 汽车网站建设预算补肾壮阳吃什么药效果好
  • php网站开发师网站怎么创建
  • 网站设计欣赏网站策划
  • 北京海淀网站建设公司网站建设公司大全
  • 字体设计在线转换器seo优化技术
  • 企业建站 炫酷模板百度知道免费提问
  • 做网站去哪个公司好网站策划书模板
  • 企业工商信息查询官网seo教程百度网盘
  • 小程序开发需要什么基础优化手机流畅度的软件