Typescript stack {val, min} solution
Code\n\nclass MinStack {\n    private stack;\n    constructor() {\n        this.stack = [];\n    }\n\n    push(val: number): void {\n        this.stack.push({\n
# Code\n```\nclass MinStack {\n    private stack;\n    constructor() {\n        this.stack = [];\n    }\n\n    push(val: number): void {\n        this.stack.push({\n            val,\n            min: this.stack.length == 0 ? val: Math.min(val, this.getMin())\n        });\n    }\n\n    pop(): void {\n        this.stack.pop();\n    }\n\n    top(): number {\n        return this.stack[this.stack.length - 1].val;\n    }\n\n    getMin(): number {\n        return this.stack.length == 0 ? 0: this.stack[this.stack.length - 1].min;\n    }\n}\n\n/**\n * Your MinStack object will be instantiated and called as such:\n * var obj = new MinStack()\n * obj.push(val)\n * obj.pop()\n * var param_3 = obj.top()\n * var param_4 = obj.getMin()\n */\n```
['TypeScript', 'JavaScript']