题解 | #栈的压入、弹出序列#
栈的压入、弹出序列
http://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106
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();
}
} 