Jane Street Interview Question

Solved a stack question in front of them