Jane Street interview question

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