Amazon Interview Question

Question related to Dynamic Programming which was HARD difficulty