Google interview question

I got dynamic programming question,