麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

LEETCODE--Number of Boomerangs

2019-11-11 04:57:17
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Find the number of boomerangs. You may assume that n will be at most 500 and coordinates of points are all in the range [-10000, 10000] (inclusive). Example: Input: [[0,0],[1,0],[2,0]]

Output: 2

Explanation: The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]]

熟悉使用map

class Solution {public: int numberOfBoomerangs(vector<pair<int, int>>& points) { int num = 0; for(int i = 0; i < points.size(); i++){ map<long,int> group; for(int j = 0; j < points.size(); j++){ if(i == j) continue; int distance_x = points[j].first - points[i].first; int distance_y = points[j].second - points[i].second; int key = distance_x * distance_x + distance_y * distance_y; ++group[key]; } for(auto& p : group){ int val = p.second; if(val > 1) num += val * (val - 1); } } return num; }};
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 国产成人自拍视频在线 | 成年人视频在线免费播放 | 国产一区亚洲 | 久久精品国产亚洲7777 | 久久久成人精品视频 | 圆产精品久久久久久久久久久 | 午夜视频在线观看91 | 91av亚洲 | 激情在线视频 | 欧洲精品久久久久69精品 | 欧美 日韩 国产 成人 | 毛片视频在线免费观看 | 香蕉秀 | 最新中文在线视频 | 污黄视频在线播放 | 欧美色另类 | 精品一区二区三区日本 | 日韩精品羞羞答答 | 成年免费大片黄在线观看岛国 | 日韩黄色影视 | 国产一区二区国产 | 91香焦视频 | 热99精品视频 | 中国av免费在线观看 | 免费一级毛片在线播放不收费 | 亚洲国产美女视频 | 美女擦逼| 成人毛片100免费观看 | 久久精品av| 国产精品1区 | 在线91视频 | 国产1区视频 | 亚洲片在线观看 | 国产91在线高潮白浆在线观看 | 最近高清无吗免费看 | 久久久精品视频国产 | 欧美精品一区自拍a毛片在线视频 | 狠狠干五月 | 中国3xxxx| 久久手机在线视频 | 亚洲视频在线网 |