Pregunta de entrevista de Optiver

Asked me to do a programming task.