Pregunta de entrevista de Nagarro

Standard question of Dynamic Programming.