Bloomberg interview question

Hackerrank question related to data structures and algorithms