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