auto commit

This commit is contained in:
CyC2018
2018-09-05 17:22:45 +08:00
parent 5fe72c31d8
commit a015b11038
4 changed files with 13 additions and 8 deletions

View File

@ -1433,7 +1433,8 @@ public boolean IsPopOrder(int[] pushSequence, int[] popSequence) {
Stack<Integer> stack = new Stack<>();
for (int pushIndex = 0, popIndex = 0; pushIndex < n; pushIndex++) {
stack.push(pushSequence[pushIndex]);
while (popIndex < n && stack.peek() == popSequence[popIndex]) {
while (popIndex < n && !stack.isEmpty()
&& stack.peek() == popSequence[popIndex]) {
stack.pop();
popIndex++;
}