HSBC Interview Question

Write a code for stack