Amazon Interview Question

a dynamic programming coding problem.