CME Group interview question

Coding question was a hard question