一边压栈一边判断,

-- coding:utf-8 --

class Solution:
def IsPopOrder(self, pushV, popV):
# write code here
temp=[]
j=0
for i in pushV:
if i!=popV[0]:
temp.append(i)
else:
popV.pop(0)
for _ in range(len(temp)):
if temp[-1] == popV[0]:
temp.pop()
popV.pop(0)
return not popV