type MinStack struct {
min []int
nums []int
}
func Constructor() MinStack {
return MinStack{}
}
func (this *Minstack) Push(x int) {
this.nums = append(this.nums, x)
if len(this.min) == 0 {
this.min = append(this.min, x)
}
if this.min[len(this.min)-1] > x {
this.min = append(this.min, x)
}else{
this.min = append(this.min, this.min[len(this.min)-1])
}
}
func (this *MinStack) Pop(){
this.nums = this.nums[:len(this.nums)-1]
this.min = this.min[:len(this.min)-1]
}
func (this *Minstack) Top() int {
return this.nums[len(this.nums)-1]
}
func (this *Minstack) Min() int {
return this.min[len(this.min)-1]
}