Amazon Interview Question

Leetcode-medium/hard level question about dynamic programming.