Google interview question

They asked a coding problem based on dp