/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param pushV int整型一维数组
* @param pushVLen int pushV数组长度
* @param popV int整型一维数组
* @param popVLen int popV数组长度
* @return bool布尔型
*/
typedef struct a{
int a[1000];
int *top;
int *bottom;
}type;
bool IsPopOrder(int* pushV, int pushVLen, int* popV, int popVLen ) {
// write code here
if(pushVLen==0||popVLen==0)return false;
type arr={{0},NULL,NULL};
int i=0,j=0,k=pushVLen;
arr.a[0]=pushV[j];
arr.bottom=arr.a;
arr.top=arr.a;
pushVLen--;
while(k){
if(i==popVLen)break;
if(arr.top!=NULL&&*(arr.top)==popV[i]){//退栈
i++;
if(arr.top!=arr.bottom){
arr.top--;
}else{
arr.top=arr.bottom=NULL;
}
}else{//入栈
k--;
if(pushVLen==0)continue;
if(arr.top!=NULL){
arr.top++;
*(arr.top)=pushV[++j];
}else{
arr.a[0]=pushV[++j];
arr.bottom=arr.a;
arr.top=arr.a;
}
pushVLen--;
}
}
if(arr.top==NULL)return true;
return false;
}