✏️

더 맵게

Question

Test Case 1

Shell
복사

Test Case 2

Shell
복사

Solve

import heapq def solution(scoville, K): answer = 0 heapq.heapify(scoville) while scoville[0] <= K and len(scoville) >= 2: mix_scoville = heapq.heappop(scoville) + heapq.heappop(scoville) * 2 heapq.heappush(scoville, mix_scoville) answer += 1 return -1 if scoville[0] < K else answer
Python
복사
실행시간 : ms