Python single stack O(1) all operations
python\nclass MinStack:\n\n    def __init__(self):\n        self.stack = []\n\n    def push(self, x):\n        if self.stack:\n\t\t\tself.stack.append(min(self.
```python\nclass MinStack:\n\n    def __init__(self):\n        self.stack = []\n\n    def push(self, x):\n        if self.stack:\n\t\t\tself.stack.append(min(self.stack[-2], x))\n        else:\n            self.stack.append(x)\n        self.stack.append(x)\n        \n\n    def pop(self):\n        if self.stack:\n            self.stack.pop()\n            self.stack.pop()\n\n    def top(self):\n        if self.stack:\n            return self.stack[-1]\n\n    def getMin(self):\n        if self.stack:\n            return self.stack[-2]\n```
[]