Java| Using 2 stacks | With Image explaination
\n\n\n\n\n\n\nclass MinStack {\n    \n    Stack stack = new Stack(); // Normal Stack\n    Stack minStack = new Stack();// Keeps the current min on top \n    \n\
![image](https://assets.leetcode.com/users/images/4f70590b-1b14-4a3f-ae5b-1049c90b86d3_1645821355.42753.jpeg)\n\n\n\n\n\n\nclass MinStack {\n    \n    Stack<Integer> stack = new Stack(); // Normal Stack\n    Stack<Integer> minStack = new Stack();// Keeps the current min on top \n    \n\n    public MinStack() {\n        \n    }\n    \n    public void push(int val) {\n\n        // First time insert. If new min found add to minStack\n        if(minStack.isEmpty() || val <=minStack.peek())\n        {\n            minStack.push(val);\n        }\n        \n        stack.push(val);\n    }\n    \n    \n    public void pop() {\n        // Pop from minStack only if top elements are same in both stacks\n        if(stack.peek().equals(minStack.peek()))\n        {\n            minStack.pop();\n        }\n        stack.pop();\n        \n        \n    }\n    \n    public int top() {\n       return stack.peek();\n    }\n    \n    public int getMin() {\n       return minStack.peek();\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 */
['Stack', 'Java']