Microsoft interview question

DP problems