下列程序的运行结果是( )
import java.util.*;
class Test{
public static void main(String[] args){
int[] pushA={1,2,4,5,3,6};
int[] popA1={4,5,2,3,1,6};
int[] popA2={4,6,5,2,3,1};
boolean res1=IsPopOrder(pushA,popA1);
boolean res2=IsPopOrder(pushA,popA2);
System.out.println(res1);
System.out.println(res2);
}
public static boolean IsPopOrder(int[] pushA,int[] popA){
if(pushA.length==0||popA.length==0) return false;
Stack<Integer> st=new Stack<Integer>();
int index=0;
for(int i=0;i<pushA.length;i++){
st.push(pushA[i]);
while(!st.empty()&&st.peek()==popA[index]){
st.pop();
index++;
}
}
return st.empty();
}
}
