BlackRock interview question

DP and recursion based coding problem