static ArrayList max_of_subarrays(int arr[], int n, int k)
{
// Your code here
Queue pq = new LinkedList<>();
ArrayList ar = new ArrayList();
int i = 0;
int j = 0;
int max = -100000;
while(j < arr.length){
if(arr[j] > max){
while(!pq.isEmpty()){
pq.remove();
}
pq.add(arr[j]);
max = arr[j];
}
else
pq.add(arr[j]);
if(j == k+i-1){
ar.add(pq.peek());
if(arr[i] == pq.peek()){
pq.remove();
}
i++;
}
j++;
}
return ar;
}