标签:stack else 队列 div describe tac one span 用两个栈
栈先进后出: 队列先进先出:
-----> A_in --------> in
<---- A_out --------> out
<---- B_in
-----> B_out
# -*- coding:utf-8 -*- class Solution: def __init__(self): self.stackA = [] self.stackB = [] def push(self, node): # write code here self.stackA.append(node) def pop(self): # return xx if self.stackB: return self.stackB.pop() elif not self.stackA: return None else: while self.stackA: self.stackB.append(self.stackA.pop()) return self.stackB.pop()
标签:stack else 队列 div describe tac one span 用两个栈
原文地址:https://www.cnblogs.com/fuj905/p/12771745.html