auto commit
This commit is contained in:
@ -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++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user