The core insight is converting everything to polar angles and running a sliding window over the sorted list.
Model each point as an angular interval on the circle, then use a sliding window over the sorted angles to find the maximum number of intervals overlapping within a window of width equal to the field of view. Handle wrap-around by duplicating the array with +360 degrees.
Pro tip: Clarify whether points on the cone boundary count as visible; this affects whether you use strict or non-strict inequalities in the sliding window. Also, mention that the optimal direction can always be chosen so that one point lies exactly on the boundary, which justifies the sliding window approach.
Confirm the field of view angle, whether boundary points count, and if points can be at the origin. Discuss handling of duplicate angles and collinear points.
Compute the polar angle of each point relative to the origin using atan2. Sort the angles in ascending order.
Duplicate the sorted angle array by adding 360 degrees to each angle to simulate the circular nature of the problem.
Use two pointers to maintain a window of angles within the field of view. Track the maximum number of points in any such window.
State that the algorithm runs in O(n log n) time due to sorting and O(n) space. Discuss potential optimizations or alternative approaches if needed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.