deno.land / x / masx200_leetcode_test@10.6.5 / queries-on-number-of-points-inside-a-circle / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export default function countPoints( points: number[][], queries: number[][],): number[] { return queries.map(([x, y, r]) => { return points.reduce((a, [n, m]) => { return a + Number(point_in_circle(n, m, x, y, r)); }, 0); });}function point_in_circle( n: number, m: number, x: number, y: number, r: number,): boolean { return r ** 2 - (n - x) ** 2 - (y - m) ** 2 >= 0; // return n <= x + r && m <= y + r && n >= x - r && m >= y - r // ? n === x // ? Math.abs(m - y) <= r // : y === m // ? Math.abs(x - n) <= r // : r ** 2 - (n - x) ** 2 - (y - m) ** 2 >= 0 // : false;}
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago