public:
    bool IsPopOrder(vector<int> pushV,vector<int> popV) {
        bool flag=true;
        stack<int> test;
        int i;
        int j=0;
        //使用暴力模拟的算法
        for(i=0;i<=pushV.size()-1;i+=1){
            while(!test.empty()&&test.top()==popV[j]){
                test.pop();
                j+=1;
            }
            
            if(pushV[i]==popV[j]){
                test.push(pushV[i]);
                test.pop();
                j+=1;
            }
            else{
                 test.push(pushV[i]); 
            } 
        }
        
        while(!test.empty()){
            if(test.top()!=popV[j]){
                flag=false;
            }
            test.pop();
            j+=1;
        }
        return flag;
    }
};