class Solution {
public:
bool IsPopOrder(vector<int> pushV,vector<int> popV) {
int n = pushV.size();
int i = 0,j = 0;
stack<int>s;
while(i < n){
s.push(pushV[i]);//将元素挨个入栈
while(!s.empty() && s.top() == popV[j]){//栈顶等于popv的元素
j++;//popv指针后移
s.pop();//栈顶弹出
}
i++;
}
return j == n;
}
};