일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 운영체제
- Python
- 밴픽
- Convert Sorted List to Binary Search Tree
- kaggle
- Python Code
- data science
- concurrency
- Protocol
- Class
- shiba
- attribute
- Python Implementation
- t1
- Generator
- 715. Range Module
- Regular Expression
- 315. Count of Smaller Numbers After Self
- Substring with Concatenation of All Words
- DWG
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- 파이썬
- LeetCode
- 프로그래머스
- iterator
- 43. Multiply Strings
- 컴퓨터의 구조
- 시바견
- Decorator
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 |