Google interview question

Online Test : Dynamic programming. Easy array problem