type MyStack struct {
A []int
}
/** Initialize your data structure here. */
func Constructor() MyStack {
return MyStack{
A: make([]int, 0),
}
}
/** Push element x onto stack. */
func (this *MyStack) Push(x int) {
this.A = append(this.A, x)
}
/** Removes the element on top of the stack and returns that element. */
func (this *MyStack) Pop() int {
x := this.A[len(this.A)-1]
this.A = this.A[:len(this.A)-1]
return x
}
/** Get the top element. */
func (this *MyStack) Top() int {
return this.A[len(this.A)-1]
}
/** Returns whether the stack is empty. */
func (this *MyStack) Empty() bool {
return len(this.A) == 0
}
/**
* Your MyStack object will be instantiated and called as such:
* obj := Constructor();
* obj.Push(x);
* param_2 := obj.Pop();
* param_3 := obj.Top();
* param_4 := obj.Empty();
*/