class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = [] self.min_stack = [] def push(self, x): """ :type x: int :rtype: None """ self.stack.append(x) if self.min_stack == []: self.min_stack.append(x) else: val = min(x, self.min_stack[-1]) self.min_stack.append(val) def pop(self): """ :rtype: None """ self.stack.pop(-1) self.min_stack.pop(-1) def top(self): """ :rtype: int """ return self.stack[-1] def min(self): """ :rtype: int """ return self.min_stack[-1]# Your MinStack object will be instantiated and called as such:# obj = MinStack()# obj.push(x)# obj.pop()# param_3 = obj.top()# param_4 = obj.min()