Pergunta de entrevista da empresa Google

classic dynamic programming problem with a twist