Pergunta de entrevista da empresa Anonymous

dynamic programming problem with a twist