Amazon interview question

A question on Dynamic programming