Class Solution
- java.lang.Object
-
- g1801_1900.s1828_queries_on_number_of_points_inside_a_circle.Solution
-
public class Solution extends Object
1828 - Queries on Number of Points Inside a Circle.Medium
You are given an array
pointswherepoints[i] = [xi, yi]is the coordinates of theithpoint on a 2D plane. Multiple points can have the same coordinates.You are also given an array
querieswherequeries[j] = [xj, yj, rj]describes a circle centered at(xj, yj)with a radius ofrj.For each query
queries[j], compute the number of points inside thejthcircle. Points on the border of the circle are considered inside.Return an array
answer, whereanswer[j]is the answer to thejthquery.Example 1:

Input: points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]]
Output: [3,2,2]
Explanation: The points and circles are shown above. queries[0] is the green circle, queries[1] is the red circle, and queries[2] is the blue circle.
Example 2:

Input: points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]]
Output: [2,3,2,4]
Explanation: The points and circles are shown above. queries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is purple.
Constraints:
1 <= points.length <= 500points[i].length == 20 <= xi, yi <= 5001 <= queries.length <= 500queries[j].length == 30 <= xj, yj <= 5001 <= rj <= 500- All coordinates are integers.
Follow up: Could you find the answer for each query in better complexity than
O(n)?
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]countPoints(int[][] points, int[][] queries)
-