https://school.programmers.co.kr/learn/courses/30/lessons/42626
import java.util.PriorityQueue;
class Solution {
public int solution(int[] scoville, int K) {
int answer = 0;
PriorityQueue<Integer> pq = new PriorityQueue<>();
for (int i = 0; i < scoville.length; i++) {
pq.offer(scoville[i]);
}
while (pq.peek() < K) {
if (pq.size() < 2) {
return -1;
}
int temp1 = pq.poll();
int temp2 = pq.poll();
int nScovile = temp1 + (temp2 * 2);
pq.offer(nScovile);
answer++;
}
return answer;
}
}