Pregunta de entrevista de Goldman Sachs

Dynamic programming in coding, explaining how and what, roughly, will solve the problem