C++ one stack
\nclass MinStack {\nprivate:\n    stack<int> s;\n    int min;\npublic:\n    /** initialize your data structure here. */\n    MinStack() {\n        min = INT_MAX
```\nclass MinStack {\nprivate:\n    stack<int> s;\n    int min;\npublic:\n    /** initialize your data structure here. */\n    MinStack() {\n        min = INT_MAX;\n    }\n    \n    void push(int x) {\n        if (x <= min)\n        {\n            s.push(min);\n            min = x;\n        }\n        s.push(x);\n    }\n    \n    void pop() {\n        if (s.top() == min)\n        {\n            s.pop();\n            min = s.top();\n            s.pop();\n        }\n        else\n        {\n            s.pop();\n        }\n    }\n    \n    int top() {\n        return s.top();\n    }\n    \n    int getMin() {\n        return min;\n    }\n};\n ```
[]