Pergunta de entrevista da empresa Jane Street

Solved a stack question in front of them