Problem · Array

Maximum Visible Drones

Learn this problem
HardAnduril logoAndurilFULLTIMEPHONE SCREEN

Problem statement

You stand at location = [x, y] while drones occupy integer-coordinate points in a two-dimensional plane. You face one direction of your choice and can see every drone whose direction from your location lies inside a viewing sector of at most angle degrees, including both boundary rays.

Drones exactly at your location are always visible, regardless of the direction you face. Multiple drones may occupy the same point. Return the maximum number of visible drones.

Function

maxVisibleDrones(points: int[][], angle: int, location: int[]) → int

Examples

Example 1

points = [[2,1],[2,2],[3,3]]angle = 90location = [1,1]return = 3

Facing northeast places all three drone directions inside a 90-degree sector.

Example 2

points = [[2,1],[2,2],[3,4],[1,1]]angle = 13location = [1,1]return = 3

The drones at angles 45 and about 56.3 degrees fit in one 13-degree sector. The drone at the observer's location is always visible.

Constraints

  • 1 <= points.length <= 100000.
  • points[i].length == 2 and location.length == 2.
  • -10^9 <= points[i][j], location[j] <= 10^9.
  • 0 <= angle <= 360.

More Anduril problems

drafts saved locally
public int maxVisibleDrones(int[][] points, int angle, int[] location) {
    // Write your code here.
}
points[[2,1],[2,2],[3,3]]
angle90
location[1,1]
expected3
checking account