本文共 361 字,大约阅读时间需要 1 分钟。
思路:新建一个栈,将数组A压入栈中,当栈顶元素等于数组B时,就将其出栈,当循环结束时,判断栈是否为空,若为空则返回true.(好好体会其中精髓)
import java.util.ArrayList;import java.util.Stack;public class Solution { public boolean IsPopOrder(int [] pushA,int [] popA) { if(pushA==null || popA==null){ return false; } Stackstack=new Stack<>(); int index=0; for(int i=0;i
转载地址:http://kourf.baihongyu.com/