Pregunta de entrevista de Jane Street

Dynamic Programming, Algorithms questions. Can code in any language.