Optiver interview question

(hackerrank questions)