Simple Java solution 12 line
class MinStack {\n\n    Stack stack=new Stack<>();\n    int min=Integer.MAX_VALUE;\n    public void push(int x) {\n        if(x<=min) {stack.push(min); min=x;}\
class MinStack {\n\n    Stack<Integer> stack=new Stack<>();\n    int min=Integer.MAX_VALUE;\n    public void push(int x) {\n        if(x<=min) {stack.push(min); min=x;}\n        stack.push(x);\n    }\n    public void pop() {\n        if(stack.peek()==min){ stack.pop(); min=stack.pop(); }\n        else stack.pop();\n    }\n    public int top() {\n        return stack.peek();\n    }\n    public int getMin() {\n        return min;\n    }\n}
['Java']