Swift solution with detailed explanation.
This implementation uses Linked List data structure approach.\n\nFirst of all we need to define linked list node.\nWe can use generic parameter "Value" to creat
**This implementation uses Linked List data structure approach.**\n\nFirst of all we need to define linked list node.\nWe can use generic parameter "Value" to create more flexible data structure. Every instance of "Node" - contains current value, minimum value and a reference to the next instance as well.\n```\nclass Node<Value> {\n\n    var next: Node?\n    var value: Value\n    var min: Value\n    \n    init(value: Value, min: Value, next: Node? = .none) {\n        self.value = value\n        self.min = min\n        self.next = next\n    }\n    \n}\n```\n**Minimum stack data structure implementation is straightforward:**\n1.  Private instance of "Node", which is nil by default.\n2.  First call of  push(_ x: Int) will init head node with brand new values of current value and min value. By the next calls we will check whether "head" is nill, if "head" is not nil - current "head" become new instance of "Node", where new minimum value will be calculated from current "min" and "x" parameter that was passed in.\n3.  To pop the top most element of stack we simply assign the next node after current to "head".\n4.  As "head" is the top element in stack, to get its value we simply look to its "value" value.\n5.  A "min()" operation works same as the top(), the only difference is that we look for "min" value.\n```\nclass MinStack {\n    \n    private var head: Node<Int>!\n    \n    func push(_ x: Int) {\n        if head == nil {\n            head = Node(value: x, min: x)\n        } else {\n            head = Node(value: x, min: min(head.min, x), next: head)\n        }\n    }\n    \n    func pop() {\n        head = head.next\n    }\n    \n    func top() -> Int {\n        return head.value\n    }\n    \n    func getMin() -> Int {\n        return head.min\n    }\n    \n}\n```\n**The Big-O notation for common operations is next:**\n1. push(_ x: Int) works in constant time complexity O(1).\n2. pop() works in constant time complexity O(1).\n3. top() works in constant time complexity O(1).\n4. getMin() works in constant time complexity O(1) as well.\n
['Linked List', 'Swift']