Pregunta de entrevista de Infosys

A question based on dynamic programming