What is wring in this


#1

vector Solution::slidingMaximum(const vector &A, int B) {
dequedq(B);
vectorres;
int i;
for(i=0;i<B;i++)
{
if(!dq.empty()&&A[dq.back()]<=A[i])
dq.pop_back();
dq.push_back(i);
}
for(;i<A.size();i++)
{
res.push_back(A[dq.front()]);//<<" ";
while(!dq.empty()&&dq.front()<=i-B)
dq.pop_front();
while(!dq.empty()&&A[dq.back()]<=A[i])
dq.pop_back();
dq.push_back(i);
}
res.push_back(A[dq.front()]);
return res;
}