Goldman Sachs Interview Question

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