Pregunta de entrevista de CME Group

Coding question was a hard question