Google interview question

A DSA question based on Dynamic Programming.