Infosys interview question

A question based on dynamic programming