Problem
Ask
Submissions

Problem: Maximum Number of Visible Points

Medium
30 min
Explore methods to determine the maximum number of points visible from a fixed location on a plane within a given viewing angle. Learn to handle integer coordinates, rotating viewing directions, and angle ranges to solve this geometric problem efficiently.

Statement

You are provided with an array, points, an integer angle, and your location, where points[i] = [xi, yi] and location = [posx, posy], both representing integer coordinatesInteger coordinates refer to points on a plane where x and y values are whole numbers. on the X-Y plane.

You initially face directly east from your fixed location and cannot move. In other words, posx and posy cannot be changed. However, you can rotate to adjust your viewing direction. Your field of view, measured in degrees, is specified by the angle, representing the width of visibility. If you rotate counterclockwise by an angle dd, your visible field spans the inclusive range of angles [dangle2,d+angle2][d-\frac{angle}{2}, d+\frac{angle}{2}].

Note: The following slide deck illustrates the observer’s location, angle, observer’s rotation, and the corresponding fields of view.

canvasAnimation-image
1 / 4

A set of points is visible to you if, for each point, the angle formed by the point, your position, and the immediate east direction from your position falls within your field of view.

There can be multiple points at one coordinate. There may be points at your location, and you can always see these points regardless of your rotation. Points do not obstruct your vision to other points.

Return the maximum number of points you can see.

Constraints:

  • 11 \leq points.length 1000\leq 1000

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

  • location.length ==2==2

  • 00 \leq angle <360< 360

  • 00 \leq posx ,,posy ,, xi ,, yi 100\leq 100

Problem
Ask
Submissions

Problem: Maximum Number of Visible Points

Medium
30 min
Explore methods to determine the maximum number of points visible from a fixed location on a plane within a given viewing angle. Learn to handle integer coordinates, rotating viewing directions, and angle ranges to solve this geometric problem efficiently.

Statement

You are provided with an array, points, an integer angle, and your location, where points[i] = [xi, yi] and location = [posx, posy], both representing integer coordinatesInteger coordinates refer to points on a plane where x and y values are whole numbers. on the X-Y plane.

You initially face directly east from your fixed location and cannot move. In other words, posx and posy cannot be changed. However, you can rotate to adjust your viewing direction. Your field of view, measured in degrees, is specified by the angle, representing the width of visibility. If you rotate counterclockwise by an angle dd, your visible field spans the inclusive range of angles [dangle2,d+angle2][d-\frac{angle}{2}, d+\frac{angle}{2}].

Note: The following slide deck illustrates the observer’s location, angle, observer’s rotation, and the corresponding fields of view.

canvasAnimation-image
1 / 4

A set of points is visible to you if, for each point, the angle formed by the point, your position, and the immediate east direction from your position falls within your field of view.

There can be multiple points at one coordinate. There may be points at your location, and you can always see these points regardless of your rotation. Points do not obstruct your vision to other points.

Return the maximum number of points you can see.

Constraints:

  • 11 \leq points.length 1000\leq 1000

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

  • location.length ==2==2

  • 00 \leq angle <360< 360

  • 00 \leq posx ,,posy ,, xi ,, yi 100\leq 100