文字不知道咋说了…看代码吧 不难
import java.util.*;
public class Solution {
public boolean IsPopOrder(int [] pushA,int [] popA) {
if(pushA.length != popA.length){
return false;
}
Stack<Integer> stack = new Stack<>();
stack.push(pushA[0]);
int i = 1;
for(int j=0;j<popA.length;j++){
int num = popA[j];
while(stack.peek() != num && i<pushA.length){
stack.push(pushA[i++]);
}
if(stack.peek() == num){
stack.pop();
continue;
}
return false;
}
return true;
}
}