摘要: 两数之和 传送门 1.indexOf 扫描当前数组,同时记录下tmp=target-nums[i]的值,通过indexOf寻找tmp是否存在于数组内,存在则返回。正序扫描:队首元素shift时,会改变数组的下标位置。因而逆序扫描,pop掉队尾的元素。 /** * @param {number[]} 阅读全文
posted @ 2021-02-23 21:39 Calculus9 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 称检测点查询 传送门 题意:找到离x,y最近的三个点 存所有的点到目标点的距离和id,将其按dis距离排序,输出前三个点的id标号。 #include<bits/stdc++.h> using namespace std; struct node{ double dis; int id; }s[10 阅读全文
posted @ 2021-02-23 16:37 Calculus9 阅读(43) 评论(0) 推荐(0) 编辑