Pregunta de entrevista de Infosys

coding question on dynamic programming