IMC Trading interview question

The second problem is implementing a stack with the increment function.