Pregunta de entrevista de Jane Street

Solve this problem and explain