American Express interview question

Dynamic programming coding challenge.