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

滴滴公司福利 1784人发布