Pergunta de entrevista da empresa Jane Street

question had three parts, didn't run code