题目:1441. 用栈操作构建数组
class Solution {
public:
vector<string> buildArray(vector<int>& target, int n) {
int cur = 1;
vector<string> res;
int m=target.size();
for(int i=0;i<m;++i){
while(target[i]>cur){
res.emplace_back("Push");
res.emplace_back("Pop");
cur++;
}
if(target[i]==cur){
cur++;
res.emplace_back("Push");
}
}
return res;
}
};