'''
解题思路:
1、正常push没问题,直接用stackin.append()
2、pop()时,当stackout为空时,stackout.append(stackin.pop()),再调用stackout.pop()输出
注意:pop()之前,要确保不为空,用if stackin/stackout:判断
'''
# -*- coding:utf-8 -*-
class Solution:
def __init__(self):
self.stackin = []
self.stackout = []
def push(self, node):
# write code here
self.stackin.append(node)
def pop(self):
# return xx
if not self.stackout:
while self.stackin:
self.stackout.append(self.stackin.pop())
if self.stackout:
return self.stackout.pop()
京公网安备 11010502036488号