用两个栈实现一个队列
代码:
class Solution:
def __init__(self):
self.first_stack = list()
self.second_stack = list()
def push(self, node):
# write code here
self.first_stack.append(node)
def pop(self):
# return xx
if len(self.second_stack) <= 0:
while len(self.first_stack) > 0:
self.second_stack.append(self.first_stack.pop())
return self.second_stack.pop()