![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbiNmno%2FbtsE0hVp3me%2FtMKhWLpOJiNncSQIUnZKR0%2Fimg.png)
Programmers / 2단계 / [힙(Heap)] 더 맵게 / python /
·
코딩테스트/programmers (python)
코딩테스트 연습 - 더 맵게 | 프로그래머스 스쿨 (programmers.co.kr) 나의 풀이 . 모범 답안 import heapq as hq def solution(scoville, K): hq.heapify(scoville) answer = 0 while True: first = hq.heappop(scoville) if first >= K: break if len(scoville) == 0: return -1 second = hq.heappop(scoville) hq.heappush(scoville, first + second*2) answer += 1 return answer import heapq def solution(scoville, K): h=[] for i in scoville: hea..