Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    1828 - Queries on Number of Points Inside a Circle\.

    Medium

    You are given an array points where <code>pointsi = x<sub>i</sub>, y<sub>i</sub></code> is the coordinates of the <code>i<sup>th</sup></code> point on a 2D plane. Multiple points can have the same coordinates.

    You are also given an array queries where <code>queriesj = x<sub>j</sub>, y<sub>j</sub>, r<sub>j</sub></code> describes a circle centered at <code>(x<sub>j</sub>, y<sub>j</sub>)</code> with a radius of <code>r<sub>j</sub></code>.

    For each query queries[j], compute the number of points inside the <code>j<sup>th</sup></code> circle. Points on the border of the circle are considered inside.

    Return an array answer, where answer[j] is the answer to the <code>j<sup>th</sup></code> query.

    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. queries0 is the green circle, queries1 is the red circle, and queries2 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. queries0 is green, queries1 is red, queries2 is blue, and queries3 is purple.

    Constraints:

    • 1 &lt;= points.length &lt;= 500

    • points[i].length == 2

    • <code>0 <= x<sub>i</sub>, y<sub>i</sub><= 500</code>

    • 1 &lt;= queries.length &lt;= 500

    • queries[j].length == 3

    • <code>0 <= x<sub>j</sub>, y<sub>j</sub><= 500</code>

    • <code>1 <= r<sub>j</sub><= 500</code>

    • All coordinates are integers.

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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final IntArray countPoints(Array<IntArray> points, Array<IntArray> queries)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait