You are viewing a single comment's thread. Return to all comments →
simple python solution
def cookies(k, A): heapq.heapify(A) count = 0 while True: c1 = heapq.heappop(A) if c1 >= k: return count if len(A) == 0: return -1 c2 = heapq.heappop(A) new_cookie = c1 + 2 * c2 heapq.heappush(A, new_cookie) count += 1 return count
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 →
simple python solution