X interview question

Dynamic programming