/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param pushV int整型一维数组 
 * @param pushVLen int pushV数组长度
 * @param popV int整型一维数组 
 * @param popVLen int popV数组长度
 * @return bool布尔型
 */
 #include<stdio.h>
 struct Stack
{
    int str[10000];
    int top;
};
typedef struct Stack* Pstack;

Pstack inistack(void)
{
    Pstack s = (struct Stack *)malloc(sizeof(struct Stack));
    s->top = -1;
    return s;
}
void push(Pstack s, int x)
{
    s->str[s->top + 1] = x;
    s->top++;
}
int pop(Pstack s)
{
    int ans;
    ans = s->str[s->top];
    s->top--;
    return ans;
}
bool IsPopOrder(int* pushV, int pushVLen, int* popV, int popVLen ) {
    // write code here
    int i, j, k, flag, m = 0, out;
    Pstack S = inistack();
    for(i = 0; i < popVLen; i++)
    {
        flag = 0;
        for(j = m; j < pushVLen; j++)
        {
            if(pushV[j] == popV[i])
            {
                flag = 1;
                for(k = m ; k < j;k++)
                push(S, pushV[k]);
                m = j+1;
                break;
            }
        }

        if(flag == 0 && pop(S) == popV[i])
        {
            continue;
        }
        printf("%d",popV[i]);
        if(flag == 0 && pop(S) != popV[i])
         return false;
    }
    return true;
    
}