소 손님 - 미끄럼 창의 최대 값
6163 단어 알고리즘 2 솔
class Solution {
public:
vector<int> maxInWindows(const vector<int>& num, unsigned int size)
{
vector<int> maxnum;//
vector<int> array;//
unsigned int length = num.size();// num
unsigned int k = 0;// num
if (size>length || size<1)
return maxnum;
while (k < size-1)
array.push_back(num[k++]);
for (int i=0; i<length-size+1; i++)
{
array.push_back(num[k++]);
maxnum.push_back(*max_element(array.begin(), array.end()));//
vector<int>::iterator idx = array.begin();
array.erase(idx);// array
}
return maxnum;
}
};