Amazon Interview Question

A dynamic programming question rated "hard" on leetcode.