class Solution:
def IsPopOrder(self, pushV, popV):
# write code here
l,j=[],0
if not pushV or not popV:
return False
for i in range(len(pushV)):
l.append(pushV[i])
while j<len(popV) and popV[j]==l[-1]:
l.pop()
j+=1
return not l
参考https://www.nowcoder.com/questionTerminal/d77d11405cc7470d82554cb392585106的思路来写的。