Problem · Array
Maximum Visible Drones
Learn this problemProblem 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[]) → intExamples
Example 1
points = [[2,1],[2,2],[3,3]]angle = 90location = [1,1]return = 3Facing 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 = 3The 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 == 2andlocation.length == 2.-10^9 <= points[i][j], location[j] <= 10^9.0 <= angle <= 360.