일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 715. Range Module
- 30. Substring with Concatenation of All Words
- 밴픽
- Convert Sorted List to Binary Search Tree
- data science
- shiba
- iterator
- Decorator
- Python Code
- 109. Convert Sorted List to Binary Search Tree
- Python Implementation
- 운영체제
- Class
- 프로그래머스
- Substring with Concatenation of All Words
- concurrency
- LeetCode
- 43. Multiply Strings
- attribute
- DWG
- 시바견
- 315. Count of Smaller Numbers After Self
- Regular Expression
- Python
- 파이썬
- 컴퓨터의 구조
- Protocol
- t1
- Generator
- kaggle
Archives
- Today
- Total
Scribbling
프로그래머스: 더 맵게 본문
import heapq
import copy
def solution(scoville, K):
answer = 0
h = copy.deepcopy(scoville)
heapq.heapify(h)
while len(h) >= 2 and h[0] < K:
f1 = heapq.heappop(h)
f2 = heapq.heappop(h)
heapq.heappush(h, (f1+2*f2))
answer += 1
if h[0] >= K:
return answer
else:
return -1
'Computer Science > Coding Test' 카테고리의 다른 글
프로그래머스: 이중 우선 순위 큐 (0) | 2021.10.16 |
---|---|
프로그래머스: 디스크 컨트롤러 (0) | 2021.10.16 |
프로그래머스: 주식 가격 (0) | 2021.10.16 |
프로그래머스: 다리를 지나는 트럭 (0) | 2021.10.15 |
LeetCode: 96. Unique Binary Search Trees (0) | 2021.10.13 |