일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- DWG
- 109. Convert Sorted List to Binary Search Tree
- Python Code
- Substring with Concatenation of All Words
- kaggle
- concurrency
- 파이썬
- 밴픽
- Convert Sorted List to Binary Search Tree
- t1
- Generator
- Protocol
- 43. Multiply Strings
- Python Implementation
- attribute
- 운영체제
- shiba
- LeetCode
- Decorator
- iterator
- 컴퓨터의 구조
- 30. Substring with Concatenation of All Words
- data science
- 715. Range Module
- 프로그래머스
- 시바견
- Class
- Regular Expression
- Python
- 315. Count of Smaller Numbers After Self
Archives
- Today
- Total
Scribbling
프로그래머스: H-Index 본문
딱 봐도 정렬 후 Binary Search하면 된다.
매번 그렇듯 프로그래머스 지문은 극혐이다.
from bisect import bisect_left
def solution(citations):
answer = 0
citations.sort()
l, r = 0, citations[len(citations) - 1]
while l <= r:
mid = (l+r) // 2
num = len(citations) - bisect_left(citations, mid)
if num >= mid:
answer = max(answer, mid)
l = mid + 1
else:
r = mid - 1
return answer
'Computer Science > Coding Test' 카테고리의 다른 글
프로그래머스: 카펫 (0) | 2021.10.19 |
---|---|
프로그래머스: 소수 찾기 (0) | 2021.10.19 |
프로그래머스: 이중 우선 순위 큐 (0) | 2021.10.16 |
프로그래머스: 디스크 컨트롤러 (0) | 2021.10.16 |
프로그래머스: 더 맵게 (0) | 2021.10.16 |