Amazon interview question

Question related to Dynamic Programming which was HARD difficulty