Amazon Interview Question

They asked me a medium difficulty dynamic programming question.