Pergunta de entrevista da empresa Hudson River Trading

Classic coding question on python