# -*- coding:utf-8 -*- class Solution: def __init__(self): self.stack1 = [] self.stack2 = [] def push(self, node): # write code here self.stack1.append(node) def pop(self): # return xx if len(self.stack2) == 0: while len(self.stack1) != 0: self.stack2.append(self.stack1[len(self.stack1)-1]) self.stack1.pop() pop = self.stack2[len(self.stack2)-1] self.stack2.pop() return pop
写个python版本的,仅供参考,已运行成功。