Jane Street Interview Question

A question related to stack, and given some operations, and ask you how would you implement it