Pregunta de entrevista de Optiver

Design a fast solution for this problem statement