Microsoft interview question

A Dynamic programming codility question