Pregunta de entrevista de FactSet

question on dynamic programming.