Infosys interview question

adding and removing element from stack