Pregunta de entrevista de IBM

Dynamic programming question, file handling.