Pregunta de entrevista de LinkedIn

It is a basic Dynamic Programming question.