Pergunta de entrevista da empresa Bloomberg

Hackerrank question related to data structures and algorithms