Open Ni-Guvara opened 1 year ago
简单难度的中等题
非常简单难度的中等难度题
class Solution {
public int[] countPoints(int[][] points, int[][] queries) {
int[] res = new int[queries.length];
for(int i = 0; i < queries.length; i++){
for(int j = 0; j < points.length; j++){
if(inCircle(points[j], queries[i])){
res[i]++;
}
}
}
return res;
}
boolean inCircle(int[] point, int[] circle){
// 圆心坐标
int cx = circle[0], cy = circle[1];
// 点坐标
int px = point[0], py = point[1];
//两点距离的平方
int distance = (cy - py) * (cy - py) + (cx - px) * (cx - px);
// 半径
int r = circle[2];
return distance <= r * r ? true : false;
}
}
你写代码能不能学习我的, 可读性!!!
我的真的那么不好看懂?