The most understandable and efficient
Intuition\nits easy when we try to think like storing a min for each val;\n\n# Approach\n Describe your approach to solving the problem. \nstoring min for each 
# Intuition\nits easy when we try to think like storing a min for each val;\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nstoring min for each entry\n\n# Complexity\n- O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n   O(n)\n\n# Code\n```\nclass MinStack {\n\n    Stack<Node>stack;\n    int min;\n    public MinStack() {\n        stack=new Stack();\n        min=Integer.MAX_VALUE;\n    }\n    \n    public void push(int val) {\n\n        if(stack.isEmpty())min=val; // if stack is empty\n        else min=Math.min(stack.peek().min,val);\n\n        stack.push(new Node(val,min));\n    }\n    \n    public void pop() {\n        stack.pop();\n    }\n    \n    public int top() {\n        return stack.peek().val;\n    }\n    \n    public int getMin() {\n        return stack.peek().min;\n    }\n}\nclass Node{\n    int min;\n    int val;\n    Node(int val,int min){\n        this.val=val;\n        this.min=min;\n    }\n}\n\n/**\n * Your MinStack object will be instantiated and called as such:\n * MinStack obj = new MinStack();\n * obj.push(val);\n * obj.pop();\n * int param_3 = obj.top();\n * int param_4 = obj.getMin();\n */\n```
['Java']