import java.util.ArrayList; import java.util.Stack;

public class Solution { public boolean IsPopOrder(int [] pushA,int [] popA) { Stack stack = new Stack<>(); Stack stack1 = new Stack<>(); for(int i = popA.length-1;i >= 0;i--) { stack1.push(popA[i]); }

    for(int i = 0;i < pushA.length;i++) {
    	stack.push(pushA[i]);
    	
    	while(!stack.empty() && !stack1.empty()) {
    		if(stack.peek().intValue()==stack1.peek().intValue()) {
	    		stack.pop();
	    		stack1.pop();
	    	}else break;
    	}
    	
    }
    
	if(stack1.empty()) return true;
    
	return false;
}

}