栈的压入、弹出序列
bool IsPopOrder(vector<int> pushV,vector<int> popV) {
bool result = false;
if(pushV.empty()||popV.empty())
return result;
if(pushV.size()!=popV.size())
return result;
stack<int> tmp;
int i=0,j=0;
while(i<pushV.size()){
/* while(pushV[i]!=popV[j]){ //每次只加入一个元素,注意注意注意
tmp.push(pushV[i]);
i++;
}*/
tmp.push(pushV[i]);
//while(popV[j]==tmp.top()){ //先判断j是否越界,注意注意注意
while(j<pushV.size()&&popV[j]==tmp.top()){
tmp.pop();
j++;
}
i++;
}
if(tmp.empty()){
result = true;
//break;
}
return result;
}