Pregunta de entrevista de Jane Street

It was a Design style leetcode question.