Philips Interview Question

Stack algorithm ,how does it work