We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 719967f commit c50a45bCopy full SHA for c50a45b
minjeong/Heap/2025-01-18-[Programmers]-더맵게.py
@@ -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
17
18
+ else:
19
+ return -1
0 commit comments