class Solution {
public:
vector<int> maxInWindows(vector<int>& nums, int k) {
int N=nums.size();
int a[N],h=0,t=-1,p=0;
vector<int> f;
for(int i=0;i<nums.size();i++)
{
if(h<=t&&i-k+1>a[h])h++;
while(h<=t&&nums[a[t]]<=nums[i])t--;
a[++t]=i;
if(i>=k-1){//printf("%d ",nums[a[h]]);
f.push_back(nums[a[h]]);}
}
// printf("\n");
return f;
}
};