Nomura interview question

Dynamic Programming array hard question