Domanda di colloquio di Uber

Haker Rank medium to difficult Dynamic Programming question.