Java | Amortized approach
java\nclass Node{\n    int data, min;\n    Node next;\n    \n    Node(int x){\n        this.data = this.min = x;\n        this.next = null;\n    }\n}\n\nclass M
```java\nclass Node{\n    int data, min;\n    Node next;\n    \n    Node(int x){\n        this.data = this.min = x;\n        this.next = null;\n    }\n}\n\nclass MinStack {\n    private Node head;\n    public void push(int x) {\n        if (head == null){\n            head = new Node(x);\n            return;\n        }\n        Node newNode = new Node(x);\n        newNode.min = Math.min(newNode.min, head.min);\n        newNode.next = head;\n        head = newNode;\n    }\n    \n    public void pop() {\n        head = head.next;\n    }\n    \n    public int top() {\n        return head.data;\n    }\n    \n    public int getMin() {\n        return head.min;\n    }\n}\n```
['Java']