Pregunta de entrevista de Google

it was Dynamic Programming question