
def solution(stones, k):
low, high = 1, max(stones)
def can_cross(n):
count = 0
for stone in stones:
if n >= stone:
count += 1
if count == k:
return False
else:
count = 0
return True
while high > low:
mid = (low + high) // 2
if can_cross(mid):
low = mid + 1
else:
high = mid
return low'코딩 테스트 > 프로그래머스 level2' 카테고리의 다른 글
| 배달 힙 다익스트라 (0) | 2025.10.16 |
|---|---|
| 보석 쇼핑(투 카운터 예제) (0) | 2025.10.01 |
| 주식가격 (stack 기본 예제) (0) | 2025.09.30 |
| 프린터 (0) | 2022.09.12 |
| k진수에서 소수 개수 구하기 (0) | 2022.09.12 |