1828. Queries on Number of Points Inside a Circle

https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle

Description

You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates.

You are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj.

For each query queries[j], compute the number of points inside the jth circle. Points on the border of the circle are considered inside.

Return an array answer, where answer[j] is the answer to the jth query.

Example 1:

Example 2:

Constraints:

  • 1 <= points.length <= 500

  • points[i].length == 2

  • 0 <= x​​​​​​i, y​​​​​​i <= 500

  • 1 <= queries.length <= 500

  • queries[j].length == 3

  • 0 <= xj, yj <= 500

  • 1 <= rj <= 500

  • All coordinates are integers.

Follow up: Could you find the answer for each query in better complexity than O(n)?

ac

Last updated

Was this helpful?