```
typedef pair<int, int> Pair;
class Solution {
public:
vector<int> maxSlidingWindow(vector<int>& nums, int k) {
vector<int> res;
if(k ==0) return res;
priority_queue<Pair> Q;
for(int i=0; i<k; i++){
Q.push(Pair(nums[i], i));
}
res.push_back(Q.top().first);
for(int i=k; i<nums.size(); i++){
while(!Q.empty() && Q.top().second <= i-k){
Q.pop();
}
Q.push(Pair (nums[i] , i));
res.push_back(Q.top().first);
}
return res;
}
};
```