Amazon interview question

a dynamic programming coding problem.