Pergunta de entrevista da empresa Google

it was Dynamic Programming question