Microsoft interview question

Algorithmic question about dynamic programing with a follow up question to make it harder