Nuveen Interview Question

LC 1-d dynamic programming problem.