Infosys Interview Question

coding question on dynamic programming