Bloomberg interview question

Data Structures & Algorithm Question