示例1
输入:
[2,3,4,2,6,2,5,1],3
返回值:
[4,4,6,6,6,5]
示例2
输入:
[9,10,9,-7,-3,8,2,-6],5
返回值:
[10,10,9,8]
示例3
输入:
[1,2,3,4],5
返回值:
[]
class Solution {
public:
vector<int> maxInWindows(const vector<int>& num, unsigned int size) {
vector<int>res;
if(size>num.size()||(size==0))
return res;
for(int i=0;i<num.size();i++)
{
vector<int >temp;
for(int j=0;j<size;j++)
{
temp.push_back(num[i+j]);
}
sort(temp.begin(),temp.end());
int tempNum=temp[size-1];
res.push_back(tempNum);
if((i+size)==num.size())
break;
}
return res;
}
};