# -*- 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 not len(self.stack1):
return None
while len(self.stack1):
self.stack2.append(self.stack1.pop())
xx = self.stack2.pop()
while len(self.stack2):
self.stack1.append(self.stack2.pop())
return xx
用两个栈实现队列python
猜你喜欢
转载自blog.csdn.net/qq_41359265/article/details/83819294
今日推荐
周排行