You are viewing a single comment's thread. Return to all comments →
java
if (A == null || A.isEmpty()) { return -1; } int count = 0; PriorityQueue<Integer> pq = new PriorityQueue<>(A); while (0 < pq.size()) { if (k <= pq.peek()) { return count; } if (pq.size() == 1) { return -1; } pq.offer(pq.poll() + 2 * pq.poll()); count++; } 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 →
java