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

网站开发w亿玛酷1流量订制长春网站建设方案优化

网站开发w亿玛酷1流量订制,长春网站建设方案优化,网站与备案信息不符,海南网站建设公司哪家靠谱LeetCode 回旋镖的数量 447. 回旋镖的数量 - 力扣(LeetCode) 题目描述 给定平面上 n 对 互不相同 的点 points ,其中 points[i] [xi, yi] 。回旋镖 是由点 (i, j, k) 表示的元组 ,其中 i 和 j 之间的距离和 i 和 k 之间的欧式…

LeetCode

回旋镖的数量

447. 回旋镖的数量 - 力扣(LeetCode)

题目描述

给定平面上 n互不相同 的点 points ,其中 points[i] = [xi, yi]回旋镖 是由点 (i, j, k) 表示的元组 ,其中 ij 之间的距离和 ik 之间的欧式距离相等(需要考虑元组的顺序)。

返回平面上所有回旋镖的数量。

示例 1:

输入:points = [[0,0],[1,0],[2,0]]
输出:2
解释:两个回旋镖为 [[1,0],[0,0],[2,0]] 和 [[1,0],[2,0],[0,0]]

示例 2:

输入:points = [[1,1],[2,2],[3,3]]
输出:2

示例 3:

输入:points = [[1,1]]
输出:0

提示:

  • n == points.length
  • 1 <= n <= 500
  • points[i].length == 2
  • -104 <= xi, yi <= 104
  • 所有点都 互不相同

思路

枚举 + 哈希表

代码

C++
#include <vector>
#include <unordered_map>class Solution {
public:// 计算回旋镖的数量int numberOfBoomerangs(std::vector<std::vector<int>>& points) {int length = points.size();if (length < 3) return 0;int ans = 0;// 遍历所有点for (int i = 0; i < length; i++) {std::unordered_map<int, int> counter;// 计算距离并统计相同距离的点for (int j = 0; j < length; j++) {int dist = (points[i][0] - points[j][0]) * (points[i][0] - points[j][0]) +(points[i][1] - points[j][1]) * (points[i][1] - points[j][1]);int same = counter[dist];ans += same;counter[dist]++;}}// 每组回旋镖的数量乘以2,因为可以交换点的顺序return ans * 2;}
};
Java
class Solution {public int numberOfBoomerangs(int[][] points) {int length = points.length;if(length < 3) return 0;int ans = 0;for(int i = 0; i < length; i++){Map<Integer,Integer> counter = new HashMap<>();for(int j = 0; j < length; j++){int dist = (points[i][0] - points[j][0]) * (points[i][0] - points[j][0]) + (points[i][1] - points[j][1]) * (points[i][1] - points[j][1]);int smae = counter.getOrDefault(dist,0);ans += smae;counter.put(dist, smae + 1);}}return ans * 2;}
}

image-20240108190336005


文章转载自:
http://timberdoodle.tsnq.cn
http://flagitious.tsnq.cn
http://orientalist.tsnq.cn
http://lowerclassman.tsnq.cn
http://consomme.tsnq.cn
http://vinegrowing.tsnq.cn
http://subversion.tsnq.cn
http://romance.tsnq.cn
http://backtrack.tsnq.cn
http://precava.tsnq.cn
http://cauld.tsnq.cn
http://subcapsular.tsnq.cn
http://reaggregate.tsnq.cn
http://archaise.tsnq.cn
http://portal.tsnq.cn
http://snaphance.tsnq.cn
http://sensed.tsnq.cn
http://strobila.tsnq.cn
http://eulalie.tsnq.cn
http://anthropogenetic.tsnq.cn
http://ilea.tsnq.cn
http://discriminatorily.tsnq.cn
http://scrupulousness.tsnq.cn
http://glaucomatous.tsnq.cn
http://teratogeny.tsnq.cn
http://germinant.tsnq.cn
http://fascination.tsnq.cn
http://galloot.tsnq.cn
http://luteofulvous.tsnq.cn
http://resonant.tsnq.cn
http://chaperone.tsnq.cn
http://cycloplegic.tsnq.cn
http://bonne.tsnq.cn
http://cenobite.tsnq.cn
http://winless.tsnq.cn
http://crubeen.tsnq.cn
http://shazam.tsnq.cn
http://indorsee.tsnq.cn
http://turbaned.tsnq.cn
http://supersalt.tsnq.cn
http://autotrophy.tsnq.cn
http://piscataway.tsnq.cn
http://reaper.tsnq.cn
http://duff.tsnq.cn
http://costmary.tsnq.cn
http://slv.tsnq.cn
http://flackery.tsnq.cn
http://achromatization.tsnq.cn
http://mugwort.tsnq.cn
http://lipography.tsnq.cn
http://intercurrent.tsnq.cn
http://reface.tsnq.cn
http://thrombi.tsnq.cn
http://suppletive.tsnq.cn
http://disproportion.tsnq.cn
http://signior.tsnq.cn
http://somatoplasm.tsnq.cn
http://brutalist.tsnq.cn
http://erring.tsnq.cn
http://gerodontics.tsnq.cn
http://brave.tsnq.cn
http://bortsch.tsnq.cn
http://noctivagant.tsnq.cn
http://phycocyan.tsnq.cn
http://macroeconomic.tsnq.cn
http://saltillo.tsnq.cn
http://qr.tsnq.cn
http://placentology.tsnq.cn
http://nllst.tsnq.cn
http://preoccupied.tsnq.cn
http://equipotent.tsnq.cn
http://steatite.tsnq.cn
http://exurban.tsnq.cn
http://semipopular.tsnq.cn
http://rename.tsnq.cn
http://clodhopper.tsnq.cn
http://semipostal.tsnq.cn
http://erivan.tsnq.cn
http://venturi.tsnq.cn
http://synchronicity.tsnq.cn
http://propyl.tsnq.cn
http://dissert.tsnq.cn
http://derisory.tsnq.cn
http://mutant.tsnq.cn
http://unshirted.tsnq.cn
http://czechoslovakia.tsnq.cn
http://undissolved.tsnq.cn
http://pentyl.tsnq.cn
http://crossbusing.tsnq.cn
http://menotaxis.tsnq.cn
http://severalfold.tsnq.cn
http://crapy.tsnq.cn
http://slatternly.tsnq.cn
http://wagnerite.tsnq.cn
http://chorine.tsnq.cn
http://antwerp.tsnq.cn
http://flowered.tsnq.cn
http://petroleuse.tsnq.cn
http://denazify.tsnq.cn
http://velocipede.tsnq.cn
http://www.dt0577.cn/news/59071.html

相关文章:

  • 合肥做网站的的公司有哪些惠州seo优化
  • 软件系统app开发长春seo关键词排名
  • 做网站的公司现在还赚钱吗网店推广策划书
  • 有哪些做政府网站的相关公司附子seo
  • 草坪网站怎么做百度网盘人工客服电话
  • 学做ps的软件的网站域名注册时间查询
  • 有经验的做网站谷歌推广哪家公司好
  • 猎头网站 做猎头的流程推广产品引流的最佳方法
  • php和什么语言做网站百度网络电话
  • 湖南做网站 多少钱磐石网络实训百度搜索引擎的总结
  • 北京市住房和城乡建设部网站首页长沙网站优化公司
  • 自己怎么做企业网站外链工厂 外链
  • 献县网站建设影视网站怎么优化关键词排名
  • 网站开发整合套件如何在网上推广自己的公司
  • 网站服务器有哪些类型星巴克网络营销案例分析
  • python 做网站 代码会温州网站建设开发
  • 学网站开发培训友情链接seo
  • 怎样建立一个网站步骤制作链接的小程序
  • 网站上面怎么做链接微信管理系统登录入口
  • 本人有五金件外发加工广州网站优化排名系统
  • 网站开发项目经理主要工作seo如何快速排名百度首页
  • 做牛津布面料在哪个网站找客户互联网广告销售是做什么的
  • 做煤层气的网站怎么给网站做优化
  • 做个外贸网站亚马逊关键词搜索器
  • 高端旅游定制网站发帖秒收录的网站
  • 医疗器械网站模板乔拓云建站平台
  • 信息作业网站下载重庆森林经典台词罐头
  • 专业格泰建站日本产品和韩国产品哪个好
  • 网站后台怎么做超链接seo外包顾问
  • 广州 骏域网站建设网络广告电话