# -*- coding:utf-8 -*-
class Solution:
def __init__(self):
self.stack = []
self.minv = None
def push(self, node):
# write code here
self.stack.append(node)
def pop(self):
# write code here
self.stack.pop()
def top(self):
# write code here
return self.stack[-1]
def min(self):
# write code here
return min(self.stack)
这样的时间复杂度是O(n)不满足要求,看了下题解,在new一个list存最小值即可。