#include <vector> class Solution { public: bool IsPopOrder(vector<int> pushV,vector<int> popV) { vector<int> m(1,pushV[0]); int j=1; for(int i=0;i<popV.size();i++){ if(m.size()==0){ m.push_back(pushV[j]); j++; } while(m[m.size()-1]!=popV[i]&&j<=pushV.size()){ m.push_back(pushV[j]); j++; } if(m[m.size()-1]==popV[i]){ m.erase(m.end()-1); } else{ return false; } } return true; } };