遍历数组取最大值
class Solution {
public:
vector<int> maxInWindows(const vector<int>& num, unsigned int size) {
vector<int> res;
int n=num.size();
if(size<=0||num.size()<size){
return res;
}
for(int i=0;i<=n-size;i++){
int t=0;
//取窗口内最大值
auto temp=std::max_element(std::begin(num)+i, std::begin(num)+i+size);
t=*temp;
res.push_back(t);
}
return res;
}
};