Pregunta de entrevista de Fractal

LC Dynamic Programming Medium level question