Pergunta de entrevista da empresa Hudson River Trading

Coding question - very hard