Pregunta de entrevista de Media.net

One question on simple implementation on dynamic programming.