Infosys interview question

coding question on dynamic programming