模拟
class Solution {
public:
vector<string> buildArray(vector<int>& target, int n) {
vector<string> ans;
int size = target.size();
for(int i = 0; i < size; i++){
if(i == 0){
if(target[i] != 1){
int num = target[i] - 1;
while(num--){
ans.push_back("Push");
ans.push_back("Pop");
}
}
ans.push_back("Push");
}else{
if(target[i] != target[i-1] + 1){
int num = target[i] - target[i-1] - 1;
while(num--){
ans.push_back("Push");
ans.push_back("Pop");
}
}
ans.push_back("Push");
}
}
return ans;
}
};