- 注意这道题没有给初始化函数,要自己初始化两个栈
- 后面使用的时候记得加self.
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 not self.stack1 and not self.stack2: return None if self.stack2 == []: while self.stack1: self.stack2.append(self.stack1.pop()) return self.stack2.pop()