Pregunta de entrevista de Intuit

it was a dynamic programming question