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