You are viewing a single comment's thread. Return to all comments →
short java8
public static int cookies(int k, List<Integer> A) { PriorityQueue<Integer> minHeap = new PriorityQueue<>(A); while( minHeap.size() > 1 && minHeap.peek() < k) minHeap.add(minHeap.poll() + minHeap.poll()*2); return minHeap.peek() >= k? A.size() - minHeap.size() : -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 →
short java8