import java.util.ArrayList; import java.util.Stack; //用辅助站完成推入和弹出序列 //当输入序列遍历完成之后,判断栈是否为空 public class Solution { public boolean IsPopOrder(int [] pushA,int [] popA) { Stack stack = new Stack(); int j = 0; for(int i = 0;i < pushA.length;i ++){ stack.push(pushA[i]); while(!stack.isEmpty() && stack.peek() == popA[j] ){ stack.pop(); j ++; } } return stack.isEmpty();
}
}