Jane Street interview question

I was asked a coding problem involving working with data structures and algorithms. The problem required writing code and explaining the reasoning throughout.