class MinStack {
constructor() {
this.result = [];
this.min = Number.MAX_SAFE_INTEGER;
}
push(x) {
this.result.push(x)
this.min = Math.min(x, this.min);
};
pop() {
let val = this.result.pop()
if (val === this.min) {
this.min = Math.min(...this.result);
}
};
top() {
return this.result[this.result.length - 1];
};
getMin() {
return this.min;
};
}