Skip to content

Commit c50a45b

Browse files
committed
[PGS] 더 맵게 / Level 2 / 60분 / 힌트,성공
1 parent 719967f commit c50a45b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import heapq
2+
3+
4+
def solution(scoville, K):
5+
answer = 0
6+
heapq.heapify(scoville)
7+
8+
while len(scoville) > 1:
9+
10+
if scoville[0] >= K:
11+
return answer
12+
mix_scoville = heapq.heappop(scoville) + (heapq.heappop(scoville) * 2)
13+
answer += 1
14+
heapq.heappush(scoville, mix_scoville)
15+
16+
if scoville[0] >= K:
17+
return answer
18+
else:
19+
return -1

0 commit comments

Comments
 (0)