1. bool IsPopOrder(vector<int> pushV,vector<int> popV) {
    2. stack<int> s;
    3. int i = 0, j = 0, len1 = pushV.size(), len2 = popV.size();
    4. while(j < len2){
    5. while(i < len1 && (s.empty() || s.top() != popV[j])){
    6. s.push(pushV[i]);
    7. ++i;
    8. }
    9. if(s.top() == popV[j]){
    10. s.pop();
    11. ++j;
    12. }else{
    13. if(i == len1)break;
    14. }
    15. }
    16. if(j == len2)return true;
    17. return false;
    18. }
    19. };