Solution using a Linked List. Clean and self-explanatory.
class MinStack {\n        class Node{\n        int value;\n        int min;\n        Node next=null;\n            Node(int x, int min){\n                value=x
    class MinStack {\n        class Node{\n        int value;\n        int min;\n        Node next=null;\n            Node(int x, int min){\n                value=x;\n                this.min=min;\n            }\n        }\n        Node head=null;\n        public void push(int x) {\n            if(head ==null){\n                head = new Node(x,x);\n            }else{\n                Node n = new Node(x, Math.min(head.min,x));\n                n.next = head;\n                head = n;\n            }\n        }\n    \n        public void pop() {\n            if(head!=null)\n                head=head.next;\n        }\n    \n        public int top() {\n            if(head!=null)\n                return head.value;\n             return -1;\n        }\n    \n        public int getMin() {\n            if(head!=null)\n                return head.min;\n            return -1;\n        }\n    }
[]