Amdocs interview question

Stack implementation