题解 | #滑动窗口的最大值#
滑动窗口的最大值
https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788
class Solution { public: vector<int> maxInWindows(const vector<int>& num, unsigned int size) { vector<int> ans; if(size>num.size()||size==0){ return ans; } for(int i=0;i<=num.size()-size;i++){ int t=num[i]; for(int j=1;j<size;j++){ t=t>num[i+j]?t:num[i+j]; } ans.push_back(t); } return ans; } };