Barclays interview question

Dynamic programming questions