class Solution:
def __init__(self):
self.stack = []
self.helper = []
def push(self, node):
self.stack.append(node)
if self.helper:
self.helper.append(min(node,self.helper[-1]))
else:
self.helper.append(node)
def pop(self):
self.stack.pop()
self.helper.pop()
def min(self):
return self.helper[-1]
def top(self):
return self.stack[-1]
网友评论