You are viewing a single comment's thread. Return to all comments →
import heapq def cookies(k, A): heapq.heapify(A) ways =0 while len(A) > 1 and A[0] < k : a = heapq.heappop(A) b = heapq.heappop(A) *2 heapq.heappush(A, (a+b)) ways +=1 if A[0] < k: return -1 return ways
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 →