class Solution:
def __init__(self):
self.stack = []
def IsPopOrder(self, pushV, popV):
# write code here
if len(pushV) != len(popV):
return False
for i in pushV:
self.stack.append(i)
while popV and self.stack[-1] == popV[0]:
self.stack.pop()
del popV[0]
if self.stack == [] and popV == []:
return True
else:
return False
网友评论