Java solution beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach \n\nThe idea is to create a doubly linkedlist and along with each node pus
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach \n\nThe idea is to create a doubly linkedlist and along with each node push current minimum till that point so that if any pop operation occur and the min value got deleted , we still have the data of prev min value in the last node. Before pushing any node we recalculate the min value as we are storing min value in last node we just grab the last node and compare the min value and push it along with the new node and update the last pointer to current pushed node.\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here,.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass MinStack {\n    \n    // private int min=Integer.MAX_VALUE;\n    private Node lst_point=null;\n    public MinStack() {\n        \n    }\n    \n    public void push(int val) {\n        int min=Math.min(val,lst_point==null? Integer.MAX_VALUE:lst_point.min);\n        Node temp=new Node(min,val);\n        if(lst_point==null)\n        {\n            lst_point=temp;\n        }\n        else{\n            lst_point.next=temp;\n            temp.prev=lst_point;\n            lst_point=lst_point.next;\n        }\n    }\n    \n    public void pop() {\n        Node temp=lst_point.prev;\n        if(temp!=null)\n        temp.next=null;\n        \n        lst_point.prev=null;\n        lst_point=temp;\n    }\n    \n    public int top() {\n        return lst_point.val;\n    }\n    \n    public int getMin() {\n        return lst_point.min;\n    }\n\n    private class Node{\n        int min;\n        int val;\n        Node next;\n        Node prev;\n        Node(int min,int val)\n        {\n            this.min=min;\n            this.val=val;\n            this.next=null;\n            this.prev=null;\n        }\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`\n
['Java']