栈的压入弹出
2019-12-21 本文已影响0人
而立之年的技术控
微信图片_20191221154119.jpg
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