import java.util.ArrayList;
import java.util.LinkedList;
public class Solution {
public boolean IsPopOrder(int [] pushA,int [] popA) {
LinkedList a = new LinkedList();
LinkedList b = new LinkedList();
for (int i : popA) {
b.add(i);
}
for (int i=0;i<pushA.length ; i++) {
a.add(pushA[i]);
while (b.get(0).equals(a.getLast())){
a.removeLast();
b.removeFirst();
if (b.size()==0){
return true;
}
if (a.size()==0){
break;
}
}
}
return false;
}
}