Java accepted solution using one stack
\nclass MinStack {\n    int min = Integer.MAX_VALUE;\n    Stack<Integer> stack = new Stack<Integer>();\n    public void push(int x) {\n        // only push the 
````\nclass MinStack {\n    int min = Integer.MAX_VALUE;\n    Stack<Integer> stack = new Stack<Integer>();\n    public void push(int x) {\n        // only push the old minimum value when the current \n        // minimum value changes after pushing the new value x\n        if(x <= min){          \n            stack.push(min);\n            min=x;\n        }\n        stack.push(x);\n    }\n\n    public void pop() {\n        // if pop operation could result in the changing of the current minimum value, \n        // pop twice and change the current minimum value to the last minimum value.\n        if(stack.pop() == min) min=stack.pop();\n    }\n\n    public int top() {\n        return stack.peek();\n    }\n\n    public int getMin() {\n        return min;\n    }\n}\n````
['Java']