Google Interview Question

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