Jane Street Interview Question

The question begins with an algorithm problem, followed by follow-up questions.