Pergunta de entrevista da empresa Amazon

A challenging dynamic programming question.