import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
int[] arr=new int[5];
arr[0]=4;
arr[1]=1;
arr[2]=3;
arr[3]=9;
arr[4]=2;
//int j=0;
//merge_sort(arr,0,5);
PriorityQueue<Integer> pq=new PriorityQueue<>(Collections.reverseOrder());
int k=4;
for(int i=0;i<5;i++){
pq.add(arr[i]);
if(pq.size()>k){
pq.poll();
}
}
System.out.println(pq.peek());
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: