The title

Points [I] = [xi, yi] represents the coordinates of the ith point on the two-dimensional plane. Multiple points might have the same coordinates.

Queries [j] = [xj, yj, rj], representing a circle whose center is at (xj, yj) and radius is rj.

For each query [J], calculate the number of points in the JTH circle. If a point is on the boundary of a circle, we also consider it to be inside the circle.

Answer [j] is the answer to the JTH query.

 

Example 1:

Input: points = [[1, 3], [3], [5], [2]], the queries = [,3,1 [2], [4,3,1], [1,1,2]] output:,2,2 [3] : all the points and the circle as shown in the above. Queries [0] are green circles, queries[1] are red circles, queries[2] are blue circles.Copy the code

Example 2:

Input: points = [[1, 1], [2], [3], [4], [5, 5]], the queries = [,2,2 [1], [2,2,2], 31 [4], [4 filling]] output:,3,2,4 [2] : all the points and the circle as shown in the above. Queries [0] are green circles, queries[1] are red circles, queries[2] are blue circles, queries[3] are purple circles.Copy the code

Their thinking

class Solution: def countPoints(self, points: List[List[int]], queries: List[List[int]]) -> List[int]: [] # for quer in queries: res = 0 for points: a, b = point[0], point[1] X, Y, R = quer[0], quer[1], quer[2] # (X-a)^2+(Y-b)^2=r^2 if (X-a)**2 + (Y-b)**2 <= R**2: res += 1 resArr.append(res) return resArr if __name__ == '__main__': Points = [[1, 3], [3], [5], [2]] queries = [,3,1 [2], [4,3,1], [1,1,2]] ret = Solution () countPoints (points, queries) print(ret)Copy the code