Nuveen interview question

LC 1-d dynamic programming problem.