155.Min Stack
class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack = [] def push(self, x: int) -> None: if len(self.stack) == 0: current_min = x else: current_min = min(x, self.stack[-1][1]) self.stack.append([x, current_min]) def pop(self) -> None: self.stack.pop() def top(self) -> int: return self.stack[-1][0] def getMin(self) -> int: return self.stack[-1][1]