Maximum Number of Visible Points LeetCode solution in Python
1# Runtime: 5206 ms (Top 8.11%) | Memory: 46.3 MB (Top 98.26%)2class Solution:3def visiblePoints(4self, points: List[List[int]], angle: int, location: List[int]5) -> int:67arr, extra = [], 08xx, yy = location910for x, y in points:11if x == xx and y == yy:12extra += 113continue14arr.append(math.atan2(y - yy, x - xx))1516arr.sort()17arr = arr + [x + 2.0 * math.pi for x in arr]18angle = math.pi * angle / 1801920l = ans = 021for r in range(len(arr)):22while arr[r] - arr[l] > angle:23l += 124ans = max(ans, r - l + 1)2526return ans + extra