入栈序列和出栈序列是否匹配

入栈序列和出栈序列是否匹配?

public boolean IsPopOrder(int[] pushA,int[] popA) {
    if(pushA == null || popA == null || pushA.length == 0 || popA.length == 0){
        return false;
    }
    if(pushA.length != popA.length){
        return false;
    }
    int length = pushA.length;
    int popIndex = 0;
    Stack<Integer> assit = new Stack<>();
    for(int i = 0; i < length;i++){
        assit.push(pushA[i]);

        while (!assit.isEmpty() && assit.peek() == popA[popIndex] && popIndex < length){
            assit.pop();
            popIndex++;
        }
    }
    return  popIndex == length;
}