题目描述
blablabla
样例
blablabla
算法1
blablabla
时间复杂度分析:blablabla
java 代码
class Solution {
public boolean isPopOrder(int [] pushV,int [] popV) {
if (popV.length==0&&pushV.length==0)
return true;
if (popV.length!=pushV.length)
return false;
Stack<Integer> stack=new Stack<>();
int i=0,j=0;
while (i<pushV.length){
stack.push(pushV[i]);
while (!stack.isEmpty()&&popV[j]==stack.peek()){
j++;
stack.pop();
}
i++;
}
return stack.isEmpty();
}
}