# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param pushV int整型一维数组 
# @param popV int整型一维数组 
# @return bool布尔型
#
class Solution:
    def IsPopOrder(self , pushV: List[int], popV: List[int]) -> bool:
        # write code here
        stack = []
        i = 0
        for ele in pushV:
            stack.append(ele)
            while stack and stack[-1] == popV[i]:
            # 这里必须用stack为真作为循环结束条件,否则会导致一个错误的死循环:当弹出序列符合顺序时,stack和popV下标都会越界
                stack.pop()
                print(stack)
                i = i + 1
        return not stack