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