Problem
Ask
Submissions

Problem: Queries on Number of Points Inside a Circle

Medium
30 min
Explore methods to count points inside or on the boundary of circles on a coordinate plane. Learn to assess each query by calculating distances and efficiently handle multiple queries. Understand the geometric concepts and algorithmic steps needed to solve such problems accurately.

Statement

Given an array of points, where each point is represented as points[i]=[xi,yi]\text = [x_i, y_i], which are the coordinates of the ithi^{th} point on an X-Y plane where some points may have identical coordinates. Additionally, given an array of queries, where each queries[j] =[xj,yj,rj]\text = [x_j, y_j, r_j] represents a circle centered at the point [xj,yj][x_j, y_j] with a radius rjr_j.

For each query, your task is to determine how many points lie within or on the boundary of the specified circle. The function should return an array answer, where answer[j] holds the number of points inside the jthj^{th} circle.

Note: Points on the circle’s edge should also be counted inside the circle.

Constraints:

  • 11 \leq points.length 100\leq 100

  • points[i].length ==2== 2

  • 0xi,yi0 \leq x_i, y_i 100\leq 100

  • 11 \leq queries.length 100\leq 100

  • queries[j].length ==3== 3

  • 0xj,yj0 \leq x_j, y_j 100\leq 100

  • 1rj1 \leq r_j 100\leq 100

Problem
Ask
Submissions

Problem: Queries on Number of Points Inside a Circle

Medium
30 min
Explore methods to count points inside or on the boundary of circles on a coordinate plane. Learn to assess each query by calculating distances and efficiently handle multiple queries. Understand the geometric concepts and algorithmic steps needed to solve such problems accurately.

Statement

Given an array of points, where each point is represented as points[i]=[xi,yi]\text = [x_i, y_i], which are the coordinates of the ithi^{th} point on an X-Y plane where some points may have identical coordinates. Additionally, given an array of queries, where each queries[j] =[xj,yj,rj]\text = [x_j, y_j, r_j] represents a circle centered at the point [xj,yj][x_j, y_j] with a radius rjr_j.

For each query, your task is to determine how many points lie within or on the boundary of the specified circle. The function should return an array answer, where answer[j] holds the number of points inside the jthj^{th} circle.

Note: Points on the circle’s edge should also be counted inside the circle.

Constraints:

  • 11 \leq points.length 100\leq 100

  • points[i].length ==2== 2

  • 0xi,yi0 \leq x_i, y_i 100\leq 100

  • 11 \leq queries.length 100\leq 100

  • queries[j].length ==3== 3

  • 0xj,yj0 \leq x_j, y_j 100\leq 100

  • 1rj1 \leq r_j 100\leq 100