class Solution {
public:
  //模拟压栈出栈的顺序
    bool IsPopOrder(vector<int>& pushV, vector<int>& popV) {
        stack<int> stk;

        int i=0;
        int n = popV.size();
        for(int a:pushV){
            stk.push(a);
            while( !stk.empty() && i<= n && stk.top() == popV[i] ){
                stk.pop();
                ++i;
            }
        }

        return (i == n)? true:false;
    }
};