题解 | #栈的压入、弹出序列#
栈的压入、弹出序列
http://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106
public class Solution {
public boolean IsPopOrder(int [] pushA,int [] popA) {
int j = 0;
Stack<Integer> stack = new Stack<>();
for(int i = 0;i < pushA.length;i ++){
stack.push(pushA[i]);
while(!stack.isEmpty() && stack.peek() == popA[j]){
stack.pop();
j++;
}
}
return j == popA.length ? true:false;
}
}
