import java.util.ArrayList;
import java.util.Stack;
public class Solution {
public boolean IsPopOrder(int [] pushA,int [] popA) {
if (pushA.length==0 || popA.length==0) return false;
Stack<Integer> ad=new Stack<>();
int n=0;
for (int i=0;i<pushA.length;i++){
ad.push(pushA[i]);
while (!ad.isEmpty()&&ad.peek()==popA[n] ){
ad.pop();
n++;
}
}
return ad.isEmpty();
}
}