The questions ask how to find n-th ugly number, which is a number only have factors 3,5,6 . For that question, design an algorithm to find the kth ugly number. In order to solve that problem, I use PriorityQueue to store possible qualified ugly numbers, PriorityQueue will sort the numbers in ascending order. But if I initialize the queue in the following way, the error comes up, it says "unexpected type, Queue queue = new PriorityQueue()".
public long kthPrimeNumber(int k) {
// write your code here
if(k<=0){
return -1;
}
Queue<int> queue = new PriorityQueue<int>();
queue.add(3);
queue.add(5);
queue.add(7);
for(int i=1; i<k;i++){
int curr = (int)queue.poll();
queue.add(curr*3);
queue.add(curr*5);
queue.add(curr*7);
}
return (long)((int)queue.poll());
}