Pregunta de entrevista de Jane Street

Algorithm implementation (with algorithm explanation given) and API implementation type problems