Amazon interview question

The first ques was a basic implementation using stacks