Partially correct solution but easy


#1

vector v;
vector c;
v.push_back(-1);
c.push_back(A[0]);
int m=A[0],top=0;
for(int i=1;i<A.size();i++){
while(top>=0){
if(A[i]>c[top]){
v.push_back(c[top]);
c.push_back(A[i]);
top++;
break;

    }
    else top--;
    }
    if (top<0) {v.push_back(-1);c.push_back(A[i]);}
    top=c.size()-1;
}
return v;