Pregunta de entrevista de AT&T

One of the questions required dynamic programming.