HSBC interview question

Write a code for stack