My java solution without build-in stack
Do not use the java stack.\n\n       class MinStack {\n            \n            Node top = null;\n            \n            public void push(int x) {\n        
Do not use the java stack.\n\n       class MinStack {\n            \n            Node top = null;\n            \n            public void push(int x) {\n                if (top == null) {\n                    top = new Node(x);\n                    top.min = x;\n                }\n                else {\n                    Node temp = new Node(x);\n                    temp.next = top;\n                    top = temp;\n                    top.min = Math.min(top.next.min, x);\n                }\n                \n                return;\n            }\n        \n            public void pop() {\n                top = top.next;\n                return;\n            }\n        \n            public int top() {\n                return top == null ? 0 : top.val;\n            }\n        \n            public int getMin() {\n                return top == null ? 0 : top.min;\n            }\n        }\n        \n        class Node {\n            int val;\n            int min;\n            Node next;\n            \n            public Node(int val) {\n                this.val = val;\n            }\n        }
[]