Nomura Interview Question

Dynamic Programming array hard question