class Solution():
def stacktest(self,stackin,stackout):
stackOrg = []
stackOrg += stackin[:stackin.index(stackout[0])+1]
stackin = stackin[stackin.index(stackout[0])+1:]
for i in stackout:
if stackOrg and i == stackOrg[-1]:
stackOrg.pop()
else:
if i not in stackin:
return False
stackOrg += stackin[:stackin.index(i)]
return True
#test
s = Solution()
print(s.stacktest([1,2,3,4,5],[1,2,3,4,5]))
网友评论