Amazon Interview Question

The first ques was a basic implementation using stacks