题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
找到每个窗口的最大值
C++ 代码
class Solution {
public:
vector<int> maxInWindows(const vector<int>& num, unsigned int size)
{
vector<int>res;
if(num.size() <size)
return res;
int index1 = 0;
int index2 = index1+size-1;
while (index2 < num.size()){
int maxv = INT_MIN;
for(int i = index1; i <= index2; i++)
maxv = max(maxv,num[i]);
res.push_back(maxv);
index1++;
index2++;
}
return res;
}
};
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度分析:blablabla
C++ 代码
blablabla