일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- t1
- 715. Range Module
- LeetCode
- Generator
- Decorator
- 30. Substring with Concatenation of All Words
- shiba
- 315. Count of Smaller Numbers After Self
- kaggle
- Python
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
- 시바견
- 밴픽
- DWG
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- attribute
- Class
- data science
- Python Code
- iterator
- concurrency
- 파이썬
- Regular Expression
- Protocol
- Python Implementation
- 운영체제
- 43. Multiply Strings
- 컴퓨터의 구조
Archives
- Today
- Total
Scribbling
LeetCode: 1610. Maximum Number of Visible Points 본문
Computer Science/Coding Test
LeetCode: 1610. Maximum Number of Visible Points
focalpoint 2022. 3. 7. 14:29class Solution:
def visiblePoints(self, points: List[List[int]], angle: int, location: List[int]) -> int:
from math import atan2, pi
from bisect import bisect_right
numLoc = 0
angles = []
for point in points:
x, y = point[0] - location[0], point[1] - location[1]
if x == 0 and y == 0:
numLoc += 1
else:
val = atan2(y, x) * 180 / pi
if val < 0:
val += 360
angles.append(val)
angles.sort()
angles += [angle+360 for angle in angles]
ret = numLoc
for i in range(len(angles)//2):
j = bisect_right(angles, angles[i]+angle)
ret = max(ret, j - i + numLoc)
return ret
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 1834. Single-Threaded CPU (0) | 2022.03.08 |
---|---|
LeetCode: 407. Trapping Rain Water II (0) | 2022.03.08 |
LeetCode: 1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix (0) | 2022.03.04 |
LeetCode: 715. Range Module (0) | 2022.03.03 |
LeetCode: 1048. Longest String Chain (0) | 2022.02.27 |