Microsoft Interview Question

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