# -*- coding:utf-8 -*- class Solution: def IsPopOrder(self, pushV, popV): # write code here if len(pushV)!=len(popV): return False if pushV==None and popV==None: return True stack=[] j=0 for i in range(0,len(popV)): if len(stack)>0: if stack[-1]==popV[i]: stack.pop() continue while (j<len(pushV)): stack.append(pushV[j]) if pushV[j]==popV[i]: stack.pop() j+=1 break j+=1 if len(stack)>0: return False else: return True