Imagine you're designing a location-based application where you need to determine how many points of interest fall within certain circular regions on a map. This is exactly what this problem asks you to solve!
You are given an array points where points[i] = [xi, yi] represents the coordinates of the i-th point on a 2D plane. Multiple points can share the same coordinates.
You are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with radius rj.
For each query, you need to count how many points lie inside or on the boundary of that circle. Points exactly on the circle's edge are considered inside.
Goal: Return an array answer where answer[j] is the number of points inside the j-th circle.
Input & Output
Visualization
Time & Space Complexity
m queries × n points, where we calculate distance for each point-query pair
Only using a few variables for calculations, result array not counted
Constraints
- 1 ≤ points.length ≤ 500
- points[i].length == 2
- 1 ≤ queries.length ≤ 500
- queries[j].length == 3
- 0 ≤ xi, yi, xj, yj ≤ 500
- 1 ≤ rj ≤ 500
- All coordinates are integers