Pergunta de entrevista da empresa Bloomberg

Dynamic programming question that was difficult