Google interview question

One DSA question based on dynamic programming. Difficulty level -high