Amazon interview question

Dynamic programming example