Pregunta de entrevista de Uber

Haker Rank medium to difficult Dynamic Programming question.