Amazon Interview Question

A question on Dynamic programming