You are viewing a single comment's thread. Return to all comments →
import heapq def cookies(k, A): operations = 0 heapq.heapify(A) while A[0] < k and len(A) > 1: heapq.heappush(A, heapq.heappop(A) + 2 * heapq.heappop(A)) operations += 1 return operations if A[0] >= k else -1
Seems like cookies are disabled on this browser, please enable them to open this website
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →