class Solution {
public:
vector<int> maxInWindows(const vector<int>& num, unsigned int size) {
vector<int> v;
deque<int> dq;
if(size > num.size() || !size) return v;
for(int i = 0; i < num.size(); ++i) {
while(!dq.empty() && num[dq.back()] < num[i]) dq.pop_back();
dq.push_back(i);
if(dq.front() + size <= i) dq.pop_front();
if(i + 1 >= size)
v.push_back(num[dq.front()]);
}
return v;
}
};